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