mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
fix tests and py2 support
This commit is contained in:
parent
d48b2027b5
commit
497bce52d2
3 changed files with 15 additions and 11 deletions
|
@ -1,7 +1,8 @@
|
|||
from Shiboken2QtExample import *
|
||||
from Shiboken2QtExample import QObjectWithEnum
|
||||
|
||||
a = QObjectWithEnum()
|
||||
a.someSignal.connect(lambda x: print("Signal emitted: %s" % x))
|
||||
a.aSlot()
|
||||
print("int(QObjectWithEnum.MyEnum.Values) =", int(QObjectWithEnum.MyEnum.Values))
|
||||
print("int(QObjectWithEnum.MyEnum.Values) =",
|
||||
int(QObjectWithEnum.MyEnum.Values))
|
||||
a.nonSlotFunction(QObjectWithEnum.MyEnum.Some)
|
||||
|
|
|
@ -82,13 +82,15 @@ class Images:
|
|||
def __loadCard(self, filename, check_w=1, check_h=1, rec=None):
|
||||
# print '__loadCard:', filename
|
||||
f = os.path.join(self.cs.dir, filename)
|
||||
img = None
|
||||
if rec and 'suit' in rec:
|
||||
# img = PIL_Image(image=self.svg.render_fragment("6_heart"))
|
||||
img = self.svg.render_fragment(
|
||||
rank=rec['rank'], suit=rec['suit'],
|
||||
width=self.CARDW, height=self.CARDH)
|
||||
img = PIL_Image(image=img)
|
||||
else:
|
||||
if img:
|
||||
img = PIL_Image(image=img)
|
||||
if not img:
|
||||
if not os.path.exists(f):
|
||||
print('card image path %s does not exist' % (f))
|
||||
return None
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
# https://stackoverflow.com/questions/22583035
|
||||
# Thanks!
|
||||
|
||||
from PySide2.QtGui import QPixmap # noqa: F401
|
||||
|
||||
from Shiboken2QtExample import MyKCardDeck
|
||||
try:
|
||||
from PySide2.QtGui import QPixmap # noqa: F401
|
||||
from Shiboken2QtExample import MyKCardDeck
|
||||
except BaseException:
|
||||
def MyKCardDeck():
|
||||
return None
|
||||
|
||||
import cairo
|
||||
# from gi import require_version
|
||||
# require_version('Rsvg', '2.0')
|
||||
# from gi.repository import Rsvg # noqa: E402
|
||||
|
||||
import pysnooper # noqa: E402
|
||||
|
||||
|
||||
from pysollib.mfxutil import Image # noqa: E402
|
||||
|
||||
|
||||
|
@ -29,7 +29,6 @@ class SVGManager:
|
|||
|
||||
# Taken from https://stackoverflow.com/questions/44471795
|
||||
# Under MIT License - thanks.
|
||||
@pysnooper.snoop()
|
||||
def pixbuf2image(self, pxb):
|
||||
""" Convert GdkPixbuf.Pixbuf to PIL image """
|
||||
data = pxb.get_pixels()
|
||||
|
@ -43,6 +42,8 @@ class SVGManager:
|
|||
return img
|
||||
|
||||
def render_fragment(self, rank, suit, width, height):
|
||||
if not self.d:
|
||||
return None
|
||||
image = Image.fromqpixmap(
|
||||
self.d.get_card_pixmap(
|
||||
rank + 1 + {'c': 0, 'd': 1, 'h': 2, 's': 3}[suit]*0x100))
|
||||
|
|
Loading…
Add table
Reference in a new issue