1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

* improved SingleGame_StatsDialog

* improved Tile/Scale
* other improvements


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@124 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-12-18 23:09:00 +00:00
parent 5ef6037db9
commit b85ff3399f
7 changed files with 88 additions and 43 deletions

View file

@ -162,7 +162,7 @@ class Calculation(Game):
for i in range(4): for i in range(4):
s.rows.append(self.RowStack_Class(x, y, self)) s.rows.append(self.RowStack_Class(x, y, self))
x = x + l.XS x = x + l.XS
self.setRegion(s.rows, (-999, y, 999999, 999999)) self.setRegion(s.rows, (-999, y-l.CH/2, 999999, 999999))
x = l.XM x = l.XM
s.talon = WasteTalonStack(x, y, self, max_rounds=1) s.talon = WasteTalonStack(x, y, self, max_rounds=1)
l.createText(s.talon, "n") l.createText(s.talon, "n")

View file

@ -971,6 +971,9 @@ class York(RelaxedSpider):
self.startDealSample() self.startDealSample()
self.s.talon.dealRow(rows=self.s.rows[2:-2]) self.s.talon.dealRow(rows=self.s.rows[2:-2])
shallHighlightMatch = Game._shallHighlightMatch_RKW
class BigYork(York): class BigYork(York):
def createGame(self): def createGame(self):

View file

@ -106,9 +106,8 @@ class FontChooserDialog(MfxDialog):
cb2.grid(row=3, column=0, columnspan=2, sticky='we') cb2.grid(row=3, column=0, columnspan=2, sticky='we')
sc = PysolScale(frame, from_=6, to=40, resolution=1, sc = PysolScale(frame, from_=6, to=40, resolution=1,
#label='Size', label=_('Size:'), orient='horizontal',
orient='horizontal', command=self.fontupdate, variable=self.size_var)
command=self.fontupdate, variable=self.size_var)
sc.grid(row=4, column=0, columnspan=2, sticky='news') sc.grid(row=4, column=0, columnspan=2, sticky='news')
# #
font_families = list(tkFont.families()) font_families = list(tkFont.families())

View file

@ -344,14 +344,13 @@ class CardsetInfoDialog(MfxDialog):
from random import choice from random import choice
im = choice(images) im = choice(images)
f = os.path.join(cardset.dir, cardset.backname) f = os.path.join(cardset.dir, cardset.backname)
self.back_image = loadImage(file=f) self.back_image = loadImage(file=f) # store the image
canvas = Tkinter.Canvas(info_frame, l = Tkinter.Label(info_frame, image=im, padding=5)
width=2*im.width()+30, l.grid(row=0, column=2, rowspan=row+1, sticky='ne')
height=im.height()+2) l = Tkinter.Label(info_frame, image=self.back_image,
canvas.create_image(10, 1, image=im, anchor='nw') padding=(0,5,5,5)) # left margin = 0
canvas.create_image(im.width()+20, 1, l.grid(row=0, column=3, rowspan=row+1, sticky='ne')
image=self.back_image, anchor='nw')
canvas.grid(row=0, column=2, rowspan=row+1, sticky='ne')
info_frame.columnconfigure(2, weight=1) info_frame.columnconfigure(2, weight=1)
info_frame.rowconfigure(row, weight=1) info_frame.rowconfigure(row, weight=1)
except: except:

View file

@ -136,18 +136,18 @@ class SingleGame_StatsDialog(MfxDialog):
return pwon, plost return pwon, plost
def _createChartInit(self, text): def _createChartInit(self, text):
w, h = self.tab_x[-1]+20, self.tab_y[-1]+20 frame = Tkinter.LabelFrame(self.top_frame, text=text)
c = Tkinter.Canvas(self.top_frame, width=w, height=h) frame.pack(side='top', fill='both', expand=False, padx=20, pady=10)
c.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=0, padx=20, pady=10) style = Tkinter.Style(self.top_frame)
self.canvas = c fg = style.lookup('.', 'foreground') or None # use default if fg == ''
##self.fg = c.cget("insertbackground") bg = style.lookup('.', 'background') or None
self.fg = c.option_get('foreground', '') or c.cget("insertbackground") self.fg = fg
# #
c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f") w, h = self.tab_x[-1]+20, self.tab_y[-1]+20
l = Tkinter.Label(c, text=text) c = Tkinter.Canvas(frame, width=w, height=h,
dy = int(self.font_metrics['ascent']) - 10 bg=bg, highlightthickness=0)
dy = dy/2 c.pack(fill='both', expand=True)
c.create_window(20, -dy, window=l, anchor="nw") self.canvas = c
def _createChartTexts(self, tx, ty, won, lost): def _createChartTexts(self, tx, ty, won, lost):
c, tfont, fg = self.canvas, self.font, self.fg c, tfont, fg = self.canvas, self.font, self.fg

View file

@ -75,6 +75,8 @@ class MfxDialog: # ex. _ToplevelDialog
self.buttons = [] self.buttons = []
self.accel_keys = {} self.accel_keys = {}
self.top = makeToplevel(parent, title=title) self.top = makeToplevel(parent, title=title)
self._frame = Tkinter.Frame(self.top)
self._frame.pack(expand=True, fill='both')
self.top.wm_resizable(resizable, resizable) self.top.wm_resizable(resizable, resizable)
##w, h = self.top.winfo_screenwidth(), self.top.winfo_screenheight() ##w, h = self.top.winfo_screenwidth(), self.top.winfo_screenheight()
##self.top.wm_maxsize(w-4, h-32) ##self.top.wm_maxsize(w-4, h-32)
@ -159,12 +161,12 @@ class MfxDialog: # ex. _ToplevelDialog
return kw return kw
def createFrames(self, kw): def createFrames(self, kw):
bottom_frame = Tkinter.Frame(self.top) bottom_frame = Tkinter.Frame(self._frame)
bottom_frame.pack(side='bottom', fill='both', expand=0, ipadx=3, ipady=3, padx=5) bottom_frame.pack(side='bottom', fill='both', expand=0, ipadx=3, ipady=3, padx=5)
if kw.separatorwidth > 0: if kw.separatorwidth > 0:
separator = Tkinter.Separator(self.top) separator = Tkinter.Separator(self._frame)
separator.pack(side='bottom', fill='x', pady=kw.separatorwidth/2) separator.pack(side='bottom', fill='x', pady=kw.separatorwidth/2)
top_frame = Tkinter.Frame(self.top) top_frame = Tkinter.Frame(self._frame)
top_frame.pack(side='top', fill='both', expand=1) top_frame.pack(side='top', fill='both', expand=1)
return top_frame, bottom_frame return top_frame, bottom_frame
@ -708,38 +710,77 @@ class StackDesc:
# /*********************************************************************** # /***********************************************************************
# // # // Tile.Scale workaround (label and resolution)
# ************************************************************************/ # ************************************************************************/
class MyPysolScale: class MyPysolScale:
def __init__(self, parent, **kw): def __init__(self, parent, **kw):
if kw.has_key('resolution'): if kw.has_key('resolution'):
self.resolution = kw['resolution'] self.resolution = kw['resolution']
del kw['resolution']
else: else:
self.resolution = 1 self.resolution = 1
if kw.has_key('from_'):
kw['from_'] = kw['from_']/self.resolution
if kw.has_key('to'):
kw['to'] = kw['to']/self.resolution
if kw.has_key('command'): if kw.has_key('command'):
self.command = kw['command'] self.command = kw['command']
else: else:
self.command = None self.command = None
self.frame = Tkinter.Frame(parent) if kw.has_key('variable'):
self.variable = kw['variable']
self.label = Tkinter.Label(self.frame) del kw['variable']
self.label.pack() else:
self.variable = None
kw['command'] = self._scale_command
self.scale = Tkinter.Scale(self.frame, **kw)
self.scale.pack(expand=True, fill='both')
if kw.has_key('value'): if kw.has_key('value'):
self.label.configure(text=self._round(kw['value'])) value = kw['value']
elif kw.has_key('variable'): del kw['value']
self.label.configure(text=self._round(kw['variable'].get())) if self.variable:
self.variable.set(value)
else:
value = None
if self.variable:
value = self.variable.get()
if self.variable:
self.variable.trace('w', self._trace_var)
kw['command'] = self._scale_command
if kw.has_key('label'):
self.label_text = kw['label']
del kw['label']
else:
self.label_text = None
# create widgets
side = 'left' # 'top'
self.frame = Tkinter.Frame(parent)
self.label = Tkinter.Label(self.frame, anchor='w', padding=(5,0))
self.label.pack(side=side, expand=False, fill='x')
self.scale = Tkinter.Scale(self.frame, **kw)
self.scale.pack(side=side, expand=True, fill='both', pady=4)
if not value is None:
if self.variable:
self.variable.set(self._round(value))
self._set_text(self._round(value))
def _round(self, value): def _round(self, value):
return int(float(value)/self.resolution)*self.resolution return int(float(value)/self.resolution)*self.resolution
def _trace_var(self, *args):
self.scale.set(float(self.variable.get())/self.resolution)
def _set_text(self, v):
if self.label_text:
t = self.label_text+' '+str(v)
else:
t = str(v)
self.label.configure(text=t)
def _scale_command(self, value): def _scale_command(self, value):
self.label.configure(text=self._round(value)) v = self._round(float(value)*self.resolution)
self._set_text(v)
self.variable.set(v)
if self.command: if self.command:
self.command(value) self.command(value)
@ -760,5 +801,5 @@ class TkinterScale(Tk.Scale):
Tk.Scale.__init__(self, parent, **kw) Tk.Scale.__init__(self, parent, **kw)
#PysolScale = MyPysolScale PysolScale = MyPysolScale
PysolScale = TkinterScale #PysolScale = TkinterScale

View file

@ -37,8 +37,11 @@ class initRootWindow(baseInitRootWindow):
if TOOLKIT == 'gtk': if TOOLKIT == 'gtk':
pass pass
elif USE_TILE: elif USE_TILE:
color = style.lookup('.', 'background')
if color:
root.tk_setPalette(color) # for non-Tile widgets
pass pass
else: else: # pure Tk
#root.option_add(...) #root.option_add(...)
pass pass