本文整理汇总了Python中tkwidget.MfxDialog.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python MfxDialog.__init__方法的具体用法?Python MfxDialog.__init__怎么用?Python MfxDialog.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkwidget.MfxDialog
的用法示例。
在下文中一共展示了MfxDialog.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, player, gameid, **kw):
self.app = app
self.selected_game = None
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.top_frame = top_frame
self.createBitmaps(top_frame, kw)
#
self.player = player or _("Demo games")
self.top.wm_minsize(200, 200)
self.button = kw.default
#
##createChart = self.create3DBarChart
createChart = self.createPieChart
##createChart = self.createSimpleChart
## if parent.winfo_screenwidth() < 800 or parent.winfo_screenheight() < 600:
## createChart = self.createPieChart
## createChart = self.createSimpleChart
#
self.font = self.app.getFont("default")
self.tk_font = tkFont.Font(self.top, self.font)
self.font_metrics = self.tk_font.metrics()
self._calc_tabs()
#
won, lost = app.stats.getStats(player, gameid)
createChart(app, won, lost, _("Total"))
won, lost = app.stats.getSessionStats(player, gameid)
createChart(app, won, lost, _("Current session"))
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
示例2: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, text, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
#
self.text_w = Tkinter.Text(top_frame, bd=1, relief="sunken", wrap="word", width=64, height=16)
self.text_w.pack(side="left", fill="both", expand=True)
###self.text_w.pack(side='top', padx=kw.padx, pady=kw.pady)
vbar = Tkinter.Scrollbar(top_frame)
vbar.pack(side="right", fill="y")
self.text_w["yscrollcommand"] = vbar.set
vbar["command"] = self.text_w.yview
#
self.text = ""
if text:
self.text = text
old_state = self.text_w["state"]
self.text_w.config(state="normal")
self.text_w.insert("insert", self.text)
self.text_w.config(state=old_state)
#
focus = self.createButtons(bottom_frame, kw)
focus = self.text_w
self.mainloop(focus, kw.timeout)
示例3: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, **kw)
#
top_box, bottom_box = self.createVBox()
#
label = gtk.Label('Please enter your name')
label.show()
top_box.pack_start(label)
self.player_entry = gtk.Entry()
self.player_entry.show()
top_box.pack_start(self.player_entry, expand=False)
completion = gtk.EntryCompletion()
self.player_entry.set_completion(completion)
model = gtk.ListStore(gobject.TYPE_STRING)
for name in app.getAllUserNames():
iter = model.append()
model.set(iter, 0, name)
completion.set_model(model)
completion.set_text_column(0)
self.player_entry.set_text(app.opt.player)
#
self.confirm_quit_check = gtk.CheckButton(_('Confirm quit'))
self.confirm_quit_check.show()
top_box.pack_start(self.confirm_quit_check)
self.confirm_quit_check.set_active(app.opt.confirm != 0)
#
self.update_stats_check = gtk.CheckButton(_('Update statistics and logs'))
self.update_stats_check.show()
top_box.pack_start(self.update_stats_check)
self.update_stats_check.set_active(app.opt.update_player_stats != 0)
#
self.createButtons(bottom_box, kw)
self.show_all()
gtk.main()
示例4: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1)
self.text_var = Tkinter.StringVar()
self.text_var.set(app.opt.colors['text'])
self.piles_var = Tkinter.StringVar()
self.piles_var.set(app.opt.colors['piles'])
self.cards_1_var = Tkinter.StringVar()
self.cards_1_var.set(app.opt.colors['cards_1'])
self.cards_2_var = Tkinter.StringVar()
self.cards_2_var.set(app.opt.colors['cards_2'])
self.samerank_1_var = Tkinter.StringVar()
self.samerank_1_var.set(app.opt.colors['samerank_1'])
self.samerank_2_var = Tkinter.StringVar()
self.samerank_2_var.set(app.opt.colors['samerank_2'])
self.hintarrow_var = Tkinter.StringVar()
self.hintarrow_var.set(app.opt.colors['hintarrow'])
self.not_matching_var = Tkinter.StringVar()
self.not_matching_var.set(app.opt.colors['not_matching'])
#
row = 0
for title, var in (
(_('Text foreground:'), self.text_var),
(_('Highlight piles:'), self.piles_var),
(_('Highlight cards 1:'), self.cards_1_var),
(_('Highlight cards 2:'), self.cards_2_var),
(_('Highlight same rank 1:'), self.samerank_1_var),
(_('Highlight same rank 2:'), self.samerank_2_var),
(_('Hint arrow:'), self.hintarrow_var),
(_('Highlight not matching:'), self.not_matching_var),
):
Tkinter.Label(frame, text=title, anchor='w',
).grid(row=row, column=0, sticky='we')
l = Tkinter.Label(frame, width=10, height=2,
bg=var.get(), textvariable=var)
l.grid(row=row, column=1, padx=5)
b = Tkinter.Button(frame, text=_('Change...'), width=10,
command=lambda l=l: self.selectColor(l))
b.grid(row=row, column=2)
row += 1
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
#
self.text_color = self.text_var.get()
self.piles_color = self.piles_var.get()
self.cards_1_color = self.cards_1_var.get()
self.cards_2_color = self.cards_2_var.get()
self.samerank_1_color = self.samerank_1_var.get()
self.samerank_2_color = self.samerank_2_var.get()
self.hintarrow_color = self.hintarrow_var.get()
self.not_matching_color = self.not_matching_var.get()
示例5: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
#self.createBitmaps(top_frame, kw)
frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1)
self.demo_sleep_var = Tkinter.DoubleVar()
self.demo_sleep_var.set(app.opt.timeouts['demo'])
self.hint_sleep_var = Tkinter.DoubleVar()
self.hint_sleep_var.set(app.opt.timeouts['hint'])
self.raise_card_sleep_var = Tkinter.DoubleVar()
self.raise_card_sleep_var.set(app.opt.timeouts['raise_card'])
self.highlight_piles_sleep_var = Tkinter.DoubleVar()
self.highlight_piles_sleep_var.set(app.opt.timeouts['highlight_piles'])
self.highlight_cards_sleep_var = Tkinter.DoubleVar()
self.highlight_cards_sleep_var.set(app.opt.timeouts['highlight_cards'])
self.highlight_samerank_sleep_var = Tkinter.DoubleVar()
self.highlight_samerank_sleep_var.set(app.opt.timeouts['highlight_samerank'])
#
lframe = ttk.LabelFrame(frame, text=_('Set delays in seconds'),
padding=(10, 5))
lframe.pack(expand=True, fill='both', padx=4)
row = 0
for title, var in (
(_('Demo:'), self.demo_sleep_var),
(_('Hint:'), self.hint_sleep_var),
(_('Raise card:'), self.raise_card_sleep_var),
(_('Highlight piles:'), self.highlight_piles_sleep_var),
(_('Highlight cards:'), self.highlight_cards_sleep_var),
(_('Highlight same rank:'), self.highlight_samerank_sleep_var),
):
ttk.Label(lframe, text=title, anchor='w'
).grid(row=row, column=0, sticky='we')
widget = PysolScale(lframe, from_=0.2, to=9.9, value=var.get(),
resolution=0.1, orient='horizontal',
length="3i", variable=var, takefocus=0)
widget.grid(row=row, column=1)
row += 1
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
#
self.demo_timeout = self.demo_sleep_var.get()
self.hint_timeout = self.hint_sleep_var.get()
self.raise_card_timeout = self.raise_card_sleep_var.get()
self.highlight_piles_timeout = self.highlight_piles_sleep_var.get()
self.highlight_cards_timeout = self.highlight_cards_sleep_var.get()
self.highlight_samerank_timeout = self.highlight_samerank_sleep_var.get()
示例6: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, manager, key=None, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, **kw)
#
top_box, bottom_box = self.createHBox()
#
if key is None:
key = manager.getSelected()
self.app = app
self.manager = manager
self.key = key
self.preview_key = -1
self.all_keys = []
if self._cardset_store is None:
self._createStore()
#padx, pady = kw.padx, kw.pady
padx, pady = 5, 5
# left
# paned
hpaned = gtk.HPaned()
self.hpaned = hpaned
hpaned.show()
top_box.pack_start(hpaned, expand=True, fill=True)
# tree
treeview = PysolTreeView(self, self._cardset_store)
self.treeview = treeview
hpaned.pack1(treeview.scrolledwindow, True, True)
##treeview.treeview.expand_all()
# right
sw = gtk.ScrolledWindow()
sw.show()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
hpaned.pack2(sw, True, True)
##self.scrolledwindow = sw
#
self.preview = MfxCanvas(self)
self.preview.show()
sw.add(self.preview)
#hpaned.pack2(self.preview, True, True)
self.preview.setTile(app, app.tabletile_index, force=True)
#
hpaned.set_position(240)
self.createButtons(bottom_box, kw)
##~self.updatePreview(key)
self.show_all()
gtk.main()
示例7: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
# self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame)
frame.pack(expand=True, fill="both", padx=5, pady=10)
frame.columnconfigure(0, weight=1)
self.demo_sleep_var = Tkinter.DoubleVar()
self.demo_sleep_var.set(app.opt.timeouts["demo"])
self.hint_sleep_var = Tkinter.DoubleVar()
self.hint_sleep_var.set(app.opt.timeouts["hint"])
self.raise_card_sleep_var = Tkinter.DoubleVar()
self.raise_card_sleep_var.set(app.opt.timeouts["raise_card"])
self.highlight_piles_sleep_var = Tkinter.DoubleVar()
self.highlight_piles_sleep_var.set(app.opt.timeouts["highlight_piles"])
self.highlight_cards_sleep_var = Tkinter.DoubleVar()
self.highlight_cards_sleep_var.set(app.opt.timeouts["highlight_cards"])
self.highlight_samerank_sleep_var = Tkinter.DoubleVar()
self.highlight_samerank_sleep_var.set(app.opt.timeouts["highlight_samerank"])
#
# Tkinter.Label(frame, text='Set delays in seconds').grid(row=0, column=0, columnspan=2)
row = 0
for title, var in (
(_("Demo:"), self.demo_sleep_var),
(_("Hint:"), self.hint_sleep_var),
(_("Raise card:"), self.raise_card_sleep_var),
(_("Highlight piles:"), self.highlight_piles_sleep_var),
(_("Highlight cards:"), self.highlight_cards_sleep_var),
(_("Highlight same rank:"), self.highlight_samerank_sleep_var),
):
Tkinter.Label(frame, text=title, anchor="w").grid(row=row, column=0, sticky="we")
widget = Tkinter.Scale(
frame, from_=0.2, to=9.9, resolution=0.1, orient="horizontal", length="3i", variable=var, takefocus=0
)
widget.grid(row=row, column=1)
row += 1
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
#
self.demo_timeout = self.demo_sleep_var.get()
self.hint_timeout = self.hint_sleep_var.get()
self.raise_card_timeout = self.raise_card_sleep_var.get()
self.highlight_piles_timeout = self.highlight_piles_sleep_var.get()
self.highlight_cards_timeout = self.highlight_cards_sleep_var.get()
self.highlight_samerank_timeout = self.highlight_samerank_sleep_var.get()
示例8: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
self.app = app
#
self.update_stats_var = Tkinter.BooleanVar()
self.update_stats_var.set(app.opt.update_player_stats != 0)
self.confirm_var = Tkinter.BooleanVar()
self.confirm_var.set(app.opt.confirm != 0)
self.win_animation_var = Tkinter.BooleanVar()
self.win_animation_var.set(app.opt.win_animation != 0)
#
frame = Tkinter.Frame(top_frame)
frame.pack(expand=True, fill="both", padx=5, pady=10)
widget = Tkinter.Label(
frame,
text=_("\nPlease enter your name"),
# justify='left', anchor='w',
takefocus=0,
)
widget.grid(row=0, column=0, columnspan=2, sticky="ew", padx=0, pady=5)
w = kw.get("e_width", 30) # width in characters
self.player_var = Tkinter.Entry(frame, exportselection=1, width=w)
self.player_var.insert(0, app.opt.player)
self.player_var.grid(row=1, column=0, sticky="ew", padx=0, pady=5)
widget = Tkinter.Button(frame, text=_("Choose..."), command=self.selectUserName)
widget.grid(row=1, column=1, padx=5, pady=5)
widget = Tkinter.Checkbutton(frame, variable=self.confirm_var, anchor="w", text=_("Confirm quit"))
widget.grid(row=2, column=0, columnspan=2, sticky="ew", padx=0, pady=5)
widget = Tkinter.Checkbutton(
frame, variable=self.update_stats_var, anchor="w", text=_("Update statistics and logs")
)
widget.grid(row=3, column=0, columnspan=2, sticky="ew", padx=0, pady=5)
### widget = Tkinter.Checkbutton(frame, variable=self.win_animation_var,
### text="Win animation")
### widget.pack(side='top', padx=kw.padx, pady=kw.pady)
frame.columnconfigure(0, weight=1)
#
self.player = self.player_var.get()
self.confirm = self.confirm_var.get()
self.update_stats = self.update_stats_var.get()
self.win_animation = self.win_animation_var.get()
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
示例9: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, manager, key=None, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
#
if key is None:
key = manager.getSelected()
self.manager = manager
self.key = key
#padx, pady = kw.padx, kw.pady
padx, pady = 5, 5
if self.TreeDataHolder_Class.data is None:
self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key)
#
self.top.wm_minsize(400, 200)
if self.top.winfo_screenwidth() >= 800:
w1, w2 = 216, 400
else:
w1, w2 = 200, 300
paned_window = Tkinter.PanedWindow(top_frame)
paned_window.pack(expand=True, fill='both')
left_frame = Tkinter.Frame(paned_window)
right_frame = Tkinter.Frame(paned_window)
paned_window.add(left_frame)
paned_window.add(right_frame)
font = app.getFont("default")
self.tree = self.Tree_Class(self, left_frame, key=key,
default=kw.default,
font=font, width=w1)
self.tree.frame.pack(fill='both', expand=True, padx=padx, pady=pady)
self.preview = MfxScrolledCanvas(right_frame, width=w2)
self.preview.setTile(app, app.tabletile_index, force=True)
self.preview.pack(fill='both', expand=True, padx=padx, pady=pady)
self.preview.canvas.preview = 1
# create a preview of the current state
self.preview_key = -1
self.preview_images = []
self.updatePreview(key)
#
focus = self.createButtons(bottom_frame, kw)
focus = self.tree.frame
self.mainloop(focus, kw.timeout)
示例10: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, gameid, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
#
self.app = app
self.gameid = gameid
self.random = None
if self.TreeDataHolder_Class.data is None:
self.TreeDataHolder_Class.data = self.TreeData_Class(app)
#
self.top.wm_minsize(200, 200)
font = app.getFont("default")
self.tree = self.Tree_Class(self, top_frame, key=gameid, font=font, default=kw.default)
self.tree.frame.pack(fill="both", expand=True, padx=kw.padx, pady=kw.pady)
#
focus = self.createButtons(bottom_frame, kw)
focus = self.tree.frame
self.mainloop(focus, kw.timeout)
示例11: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, manager, key=None, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
#
if key is None:
key = manager.getSelected()
self.app = app
self.manager = manager
self.key = key
self.table_color = app.opt.colors['table']
if self.TreeDataHolder_Class.data is None:
self.TreeDataHolder_Class.data = self.TreeData_Class(manager, key)
#
self.top.wm_minsize(400, 200)
if self.top.winfo_screenwidth() >= 800:
w1, w2 = 200, 400
else:
w1, w2 = 200, 300
font = app.getFont("default")
padx, pady = 4, 4
frame = Tkinter.Frame(top_frame)
frame.pack(fill='both', expand=True,
padx=kw.padx-padx, pady=kw.pady-pady)
self.tree = self.Tree_Class(self, frame, key=key,
default=kw.default,
font=font, width=w1)
self.tree.frame.pack(side="left", fill='both', expand=False,
padx=padx, pady=pady)
self.preview = MfxScrolledCanvas(frame, width=w2, hbar=0, vbar=0)
self.preview.pack(side="right", fill='both', expand=True,
padx=padx, pady=pady)
self.preview.canvas.preview = 1
# create a preview of the current state
self.preview_key = -1
self.updatePreview(key)
#
focus = self.createButtons(bottom_frame, kw)
focus = self.tree.frame
self.mainloop(focus, kw.timeout)
示例12: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1)
self.fonts = {}
row = 0
for fn, title in (##('default', _('Default')),
('sans', _('HTML: ')),
('small', _('Small: ')),
('fixed', _('Fixed: ')),
('canvas_default', _('Tableau default: ')),
('canvas_fixed', _('Tableau fixed: ')),
('canvas_large', _('Tableau large: ')),
('canvas_small', _('Tableau small: ')),
):
font = app.opt.fonts[fn]
self.fonts[fn] = font
Tkinter.Label(frame, text=title, anchor='w'
).grid(row=row, column=0, sticky='we')
if font:
title = ' '.join([str(i) for i in font if i not in ('roman', 'normal')])
elif font is None:
title = 'Default'
l = Tkinter.Label(frame, font=font, text=title)
l.grid(row=row, column=1)
b = Tkinter.Button(frame, text=_('Change...'), width=10,
command=lambda l=l, fn=fn: self.selectFont(l, fn))
b.grid(row=row, column=2)
row += 1
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
示例13: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, manager, key=None, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, **kw)
#
top_box, bottom_box = self.createHBox()
#
if key is None:
key = manager.getSelected()
self.app = app
self.manager = manager
self.key = key
self.preview_key = -1
self.all_keys = []
self.table_color = app.opt.colors['table']
# paned
hpaned = gtk.HPaned()
self.hpaned = hpaned
hpaned.show()
top_box.pack_start(hpaned, expand=True, fill=True)
#
model = self._createStore(manager, key)
treeview = PysolTreeView(self, model)
self.treeview = treeview
hpaned.pack1(treeview.scrolledwindow, True, True)
treeview.treeview.expand_all()
#
self.preview = MfxCanvas(top_box) # width=w2
hpaned.pack2(self.preview, True, True)
self.preview.show()
hpaned.set_position(240)
self.createButtons(bottom_box, kw)
self.updatePreview(key)
self.show_all()
gtk.main()
示例14: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, title, app, gameid, bookmark=None, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, **kw)
#
self.app = app
self.gameid = gameid
self.bookmark = bookmark
self.random = None
#
if self.game_store is None:
self.createGameStore()
#
top_box, bottom_box = self.createHBox()
# paned
hpaned = gtk.HPaned()
self.hpaned = hpaned
hpaned.show()
top_box.pack_start(hpaned, expand=True, fill=True)
# left
self.treeview = PysolTreeView(self, self.game_store)
hpaned.pack1(self.treeview.scrolledwindow, True, True)
# right
table = gtk.Table(2, 2, False)
table.show()
hpaned.pack2(table, True, True)
# frames
frame = gtk.Frame(label=_('About game'))
frame.show()
table.attach(frame,
0, 1, 0, 1,
gtk.FILL, gtk.FILL,
0, 0)
frame.set_border_width(4)
info_frame = gtk.Table(2, 7, False)
info_frame.show()
frame.add(info_frame)
info_frame.set_border_width(4)
#
frame = gtk.Frame(label=_('Statistics'))
frame.show()
table.attach(frame,
1, 2, 0, 1,
gtk.FILL, gtk.FILL,
0, 0)
frame.set_border_width(4)
stats_frame = gtk.Table(2, 6, False)
stats_frame.show()
frame.add(stats_frame)
stats_frame.set_border_width(4)
# info
self.info_labels = {}
i = 0
for n, t, f, row in (
('name', _('Name:'), info_frame, 0),
('altnames', _('Alternate names:'), info_frame, 1),
('category', _('Category:'), info_frame, 2),
('type', _('Type:'), info_frame, 3),
('skill_level', _('Skill level:'), info_frame, 4),
('decks', _('Decks:'), info_frame, 5),
('redeals', _('Redeals:'), info_frame, 6),
#
('played', _('Played:'), stats_frame, 0),
('won', _('Won:'), stats_frame, 1),
('lost', _('Lost:'), stats_frame, 2),
('time', _('Playing time:'), stats_frame, 3),
('moves', _('Moves:'), stats_frame, 4),
('percent', _('% won:'), stats_frame, 5),
):
title_label = gtk.Label()
title_label.show()
title_label.set_text(t)
title_label.set_alignment(0., 0.)
title_label.set_property('xpad', 2)
title_label.set_property('ypad', 2)
f.attach(title_label,
0, 1, row, row+1,
gtk.FILL, 0,
0, 0)
text_label = gtk.Label()
text_label.show()
text_label.set_alignment(0., 0.)
text_label.set_property('xpad', 2)
text_label.set_property('ypad', 2)
f.attach(text_label,
1, 2, row, row+1,
gtk.FILL, 0,
0, 0)
self.info_labels[n] = (title_label, text_label)
# canvas
self.preview = MfxCanvas(self)
self.preview.show()
table.attach(self.preview,
0, 2, 1, 2,
gtk.EXPAND|gtk.FILL|gtk.SHRINK, gtk.EXPAND|gtk.FILL|gtk.SHRINK,
0, 0)
self.preview.set_border_width(4)
self.preview.setTile(app, app.tabletile_index, force=True)
# set the scale factor
self.preview.preview = 2
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from tkwidget import MfxDialog [as 别名]
# 或者: from tkwidget.MfxDialog import __init__ [as 别名]
def __init__(self, parent, app, **kw):
self.parent = parent
self.app = app
title = TITLE+' - FreeCell Solver'
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
#
self.solving_methods = {
'A*': 'a-star',
'Breadth-First Search': 'bfs',
'Depth-First Search': 'soft-dfs', # default
'A randomized DFS': 'random-dfs',
##'"Soft" DFS': 'soft-dfs',
}
self.games = {} # key: gamename; value: gameid
#
frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=4, pady=4)
frame.columnconfigure(1, weight=1)
#
row = 0
ttk.Label(frame, text=_('Game:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
games = app.getGamesForSolver()
gamenames = ['']
for id in games:
name = app.getGameTitleName(id)
gamenames.append(name)
self.games[name] = id
gamenames.sort()
self.gamenames = gamenames
cb = PysolCombo(frame, values=tuple(gamenames),
selectcommand=self.gameSelected,
state='readonly', width=40)
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
self.games_var = cb
#
row += 1
ttk.Label(frame, text=_('Solving method:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
##sm = self.solving_methods.values()
##sm.sort()
sm = ['A*',
'Breadth-First Search',
'Depth-First Search',
'A randomized DFS',
##'"Soft" DFS'
]
cb = PysolCombo(frame, values=tuple(sm), state='readonly')
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
cb.current(sm.index('Depth-First Search'))
self.solving_method_var = cb
#
row += 1
ttk.Label(frame, text=_('Preset:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
presets = [
'none',
'abra-kadabra',
'cool-jives',
'crooked-nose',
'fools-gold',
'good-intentions',
'hello-world',
'john-galt-line',
'rin-tin-tin',
'yellow-brick-road',
]
self.presets = presets
cb = PysolCombo(frame, values=tuple(presets), state='readonly')
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
cb.current(0)
self.preset_var = cb
#
row += 1
self.max_iters_var = Tkinter.IntVar()
self.max_iters_var.set(10e4)
ttk.Label(frame, text=_('Max iterations:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
spin = Tkinter.Spinbox(frame, bg='white', from_=1000, to=10e6,
increment=1000, textvariable=self.max_iters_var)
spin.grid(row=row, column=1, sticky='w', padx=2, pady=2)
#
row += 1
self.max_depth_var = Tkinter.IntVar()
self.max_depth_var.set(1000)
ttk.Label(frame, text=_('Max depth:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
spin = Tkinter.Spinbox(frame, bg='white', from_=100, to=10000,
increment=100, textvariable=self.max_depth_var)
spin.grid(row=row, column=1, sticky='w', padx=2, pady=2)
#.........这里部分代码省略.........