Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 def mDone(self, button):
     if button in (0, 1):  # Load/Cancel
         self.key = self.tree.selection_key
         self.tree.n_expansions = 1  # save xyview in any case
         if USE_PIL:
             auto_scale = bool(self.auto_scale.get())
             if button == 1:
                 self.app.menubar.tkopt.auto_scale.set(auto_scale)
             if auto_scale:
                 self.scale_values = (self.app.opt.scale_x,
                                      self.app.opt.scale_y, auto_scale,
                                      bool(self.preserve_aspect.get()))
             else:
                 self.scale_values = (self.scale_x.get(),
                                      self.scale_y.get(), auto_scale,
                                      self.app.opt.preserve_aspect_ratio)
     if button == 10:  # Info
         cs = self.manager.get(self.tree.selection_key)
         if not cs:
             return
         # title = CARDSET+" "+cs.name
         title = CARDSET.capitalize() + " " + cs.name
         d = CardsetInfoDialog(self.top,
                               title=title,
                               cardset=cs,
                               images=self.preview_images)
         self.cardset_values = d.cardset_values
         return
     MfxDialog.mDone(self, button)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 def mDone(self, button):
     if button in (0, 1):            # Load/Cancel
         self.key = self.tree.selection_key
         self.tree.n_expansions = 1  # save xyview in any case
         if USE_PIL:
             auto_scale = bool(self.auto_scale.get())
             if button == 1:
                 self.app.menubar.tkopt.auto_scale.set(auto_scale)
             if auto_scale:
                 self.scale_values = (self.app.opt.scale_x,
                                      self.app.opt.scale_y,
                                      auto_scale,
                                      bool(self.preserve_aspect.get()))
             else:
                 self.scale_values = (self.scale_x.get(),
                                      self.scale_y.get(),
                                      auto_scale,
                                      self.app.opt.preserve_aspect_ratio)
     if button in (3, 4):
         cs = self.manager.get(self.tree.selection_key)
         if not cs:
             return
         ##title = CARDSET+" "+cs.name
         title = CARDSET.capitalize()+" "+cs.name
         CardsetInfoDialog(self.top, title=title, cardset=cs, images=self.preview_images)
         return
     MfxDialog.mDone(self, button)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
    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()
Ejemplo n.º 9
0
    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()
Ejemplo n.º 10
0
    def __init__(self, parent, title, top, **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)

        cnf = {
            'master': top_frame,
            'highlightthickness': 1,
            'highlightbackground': 'black',
        }
        frame = Tkinter.Frame(**cnf)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)
        cnf['master'] = frame
        cnf['text'] = _('N')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=0, sticky='ew')
        cnf['text'] = _('Game number')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=1, sticky='ew')
        cnf['text'] = _('Started at')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=2, sticky='ew')
        cnf['text'] = _('Result')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=3, sticky='ew')

        row = 1
        for i in top:
            # N
            cnf['text'] = str(row)
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=0, sticky='ew')
            # Game number
            cnf['text'] = '#' + str(i.game_number)
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=1, sticky='ew')
            # Start time
            t = time.strftime('%Y-%m-%d %H:%M',
                              time.localtime(i.game_start_time))
            cnf['text'] = t
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=2, sticky='ew')
            # Result
            if isinstance(i.value, float):
                # time
                s = format_time(i.value)
            else:
                # moves
                s = str(i.value)
            cnf['text'] = s
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=3, sticky='ew')
            row += 1

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
Ejemplo n.º 11
0
    def __init__(self, parent, title, top, **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)

        cnf = {'master': top_frame,
               'highlightthickness': 1,
               'highlightbackground': 'black',
               }
        frame = Tkinter.Frame(**cnf)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)
        cnf['master'] = frame
        cnf['text'] = _('N')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=0, sticky='ew')
        cnf['text'] = _('Game number')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=1, sticky='ew')
        cnf['text'] = _('Started at')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=2, sticky='ew')
        cnf['text'] = _('Result')
        l = Tkinter.Label(**cnf)
        l.grid(row=0, column=3, sticky='ew')

        row = 1
        for i in top:
            # N
            cnf['text'] = str(row)
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=0, sticky='ew')
            # Game number
            cnf['text'] = '#'+str(i.game_number)
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=1, sticky='ew')
            # Start time
            t = time.strftime('%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
            cnf['text'] = t
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=2, sticky='ew')
            # Result
            if isinstance(i.value, float):
                # time
                s = format_time(i.value)
            else:
                # moves
                s = str(i.value)
            cnf['text'] = s
            l = Tkinter.Label(**cnf)
            l.grid(row=row, column=3, sticky='ew')
            row += 1

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
Ejemplo n.º 12
0
 def mDone(self, button):
     if button == 0:  # Ok or double click
         self.gameid = self.tree.selection_key
         self.tree.n_expansions = 1  # save xyview in any case
     if button == 1:  # Rules
         doc = self.app.getGameRulesFilename(self.tree.selection_key)
         if not doc:
             return
         dir = os.path.join("html", "rules")
         help_html(self.app, doc, dir, self.top)
         return
     MfxDialog.mDone(self, button)
Ejemplo n.º 13
0
 def mDone(self, button):
     self.selected_game = self.all_games_frame.getSelectedGame()
     w = self.notebook.select()
     indx = self.notebook_tabs.index(w)
     StatsDialog.SELECTED_TAB = indx
     if button == 500:               # "Reset..."
         assert indx in (0, 1)
         if indx == 0:               # "Current game"
             button = 302
         else:                       # "All games"
             button = 301
     MfxDialog.mDone(self, button)
Ejemplo n.º 14
0
 def mDone(self, button):
     self.selected_game = self.all_games_frame.getSelectedGame()
     w = self.notebook.select()
     indx = self.notebook_tabs.index(w)
     StatsDialog.SELECTED_TAB = indx
     if button == 500:  # "Reset..."
         assert indx in (0, 1)
         if indx == 0:  # "Current game"
             button = 302
         else:  # "All games"
             button = 301
     MfxDialog.mDone(self, button)
Ejemplo n.º 15
0
 def mDone(self, button):
     ##self.selected_game = self.all_games_frame.getSelectedGame()
     w = self.notebook.select()
     indx = self.notebook_tabs.index(w)
     LogDialog.SELECTED_TAB = indx
     if button == 500:  # "Save to file"
         assert indx in (0, 1)
         if indx == 0:  # "Full log"
             button = 203
         else:  # "Session log"
             button = 204
     MfxDialog.mDone(self, button)
Ejemplo n.º 16
0
 def mDone(self, button):
     ##self.selected_game = self.all_games_frame.getSelectedGame()
     w = self.notebook.select()
     indx = self.notebook_tabs.index(w)
     LogDialog.SELECTED_TAB = indx
     if button == 500:               # "Save to file"
         assert indx in (0, 1)
         if indx == 0:               # "Full log"
             button = 203
         else:                       # "Session log"
             button = 204
     MfxDialog.mDone(self, button)
Ejemplo n.º 17
0
 def mDone(self, button):
     if button == 0:  # Ok or double click
         self.gameid = self.tree.selection_key
         self.tree.n_expansions = 1  # save xyview in any case
     if button == 1:  # Rules
         doc = self.app.getGameRulesFilename(self.tree.selection_key)
         if not doc:
             return
         dir = os.path.join("html", "rules")
         help_html(self.app, doc, dir, self.top)
         return
     MfxDialog.mDone(self, button)
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
    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()
Ejemplo n.º 20
0
 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)
Ejemplo n.º 21
0
 def mDone(self, button):
     if button in (0, 1):               # Ok/Load
         self.key = self.tree.selection_key
         self.tree.n_expansions = 1  # save xyview in any case
     if button in (3, 4):
         cs = self.manager.get(self.tree.selection_key)
         if not cs:
             return
         ##title = CARDSET+" "+cs.name
         title = CARDSET.capitalize()+" "+cs.name
         CardsetInfoDialog(self.top, title=title, cardset=cs, images=self.preview_images)
         return
     MfxDialog.mDone(self, button)
Ejemplo n.º 22
0
    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()
Ejemplo n.º 23
0
    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()
Ejemplo n.º 24
0
    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()
Ejemplo n.º 25
0
    def __init__(self, parent, title, app, player, gameid, **kw):

        kw = self.initKw(kw)
        title = _('Statistics')
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

        self.font = app.getFont('default')
        self.tkfont = tkFont.Font(parent, self.font)
        self.font_metrics = self.tkfont.metrics()
        style = ttk.Style(parent)
        heading_font = style.lookup('Heading', 'font')  # treeview heading
        self.heading_tkfont = tkFont.Font(parent, heading_font)

        self.selected_game = None

        top_frame, bottom_frame = self.createFrames(kw)
        notebook = ttk.Notebook(top_frame)
        notebook.pack(expand=True, fill='both', padx=10, pady=10)

        self.notebook_tabs = []

        single_frame = SingleGameFrame(self, notebook, app, player, gameid)
        notebook.add(single_frame, text=_('Current game'))
        self.notebook_tabs.append(single_frame._w)

        all_frame = AllGamesFrame(self, notebook, app, player)
        notebook.add(all_frame, text=_('All games'))
        self.all_games_frame = all_frame
        self.notebook_tabs.append(all_frame._w)

        top_frame = TopFrame(self, notebook, app, player, gameid)
        notebook.add(top_frame, text=TOP_TITLE)
        self.notebook_tabs.append(top_frame._w)

        if player is not None:
            progr_frame = ProgressionFrame(self, notebook, app, player, gameid)
            notebook.add(progr_frame, text=_('Progression'))
            self.notebook_tabs.append(progr_frame._w)

        if StatsDialog.SELECTED_TAB < len(self.notebook_tabs):
            notebook.select(StatsDialog.SELECTED_TAB)
        bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)
        ##notebook.enableTraversal()
        self.notebook = notebook

        focus = self.createButtons(bottom_frame, kw)
        self.tabChanged()  # configure buttons state
        self.mainloop(focus, kw.timeout)
Ejemplo n.º 26
0
    def __init__(self, parent, title, app, player, gameid, **kw):

        kw = self.initKw(kw)
        title = _('Statistics')
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

        self.font = app.getFont('default')
        self.tkfont = tkFont.Font(parent, self.font)
        self.font_metrics = self.tkfont.metrics()
        style = ttk.Style(parent)
        heading_font = style.lookup('Heading', 'font') # treeview heading
        self.heading_tkfont = tkFont.Font(parent, heading_font)

        self.selected_game = None

        top_frame, bottom_frame = self.createFrames(kw)
        notebook = ttk.Notebook(top_frame)
        notebook.pack(expand=True, fill='both', padx=10, pady=10)

        self.notebook_tabs = []

        single_frame = SingleGameFrame(self, notebook, app, player, gameid)
        notebook.add(single_frame, text=_('Current game'))
        self.notebook_tabs.append(single_frame._w)

        all_frame = AllGamesFrame(self, notebook, app, player)
        notebook.add(all_frame, text=_('All games'))
        self.all_games_frame = all_frame
        self.notebook_tabs.append(all_frame._w)

        top_frame = TopFrame(self, notebook, app, player, gameid)
        notebook.add(top_frame, text=TOP_TITLE)
        self.notebook_tabs.append(top_frame._w)

        if player is not None:
            progr_frame = ProgressionFrame(self, notebook, app, player, gameid)
            notebook.add(progr_frame, text=_('Progression'))
            self.notebook_tabs.append(progr_frame._w)

        if StatsDialog.SELECTED_TAB < len(self.notebook_tabs):
            notebook.select(StatsDialog.SELECTED_TAB)
        bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)
        ##notebook.enableTraversal()
        self.notebook = notebook

        focus = self.createButtons(bottom_frame, kw)
        self.tabChanged()               # configure buttons state
        self.mainloop(focus, kw.timeout)
Ejemplo n.º 27
0
 def initKw(self, kw):
     kwdefault(kw,
               strings=(_("&Select"), _("&Rules"), _("&Cancel"),),
               default=0,
               width=600, height=400,
               )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 28
0
 def initKw(self, kw):
     kw = KwStruct(
         kw,
         strings=(_('&OK'), _('&Cancel')),
         default=0,
     )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 29
0
 def initKw(self, kw):
     strings=[_("&OK"), _("&Apply"), _("&Cancel"),]
     kw = KwStruct(kw,
                   strings=strings,
                   default=0,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 30
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(_('&OK'), _('&Cancel')),
                   default=0,
                   separator=False,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 31
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(None, None, _("&Cancel"),), default=0,
                   resizable=True,
                   separator=True,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 32
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(_("&OK"),),
                   default=0,
                   separator=True,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 33
0
 def initKw(self, kw):
     kwdefault(kw,
               strings=(_("&Select"), _("&Rules"), _("&Cancel"),),
               default=0,
               width=600, height=400,
               )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 34
0
 def initKw(self, kw):
     strings=[_('&Start'), _('&Play'), _('&New'), 'sep', _('&Close'),]
     kw = KwStruct(kw,
                   strings=strings,
                   default=0,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 35
0
 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)
Ejemplo n.º 36
0
 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 = ttk.Frame(top_frame)
     frame.pack(expand=True, fill='both', padx=5, pady=10)
     widget = ttk.Label(frame,
                        text=_("\nPlease enter your name"),
                        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
     names = self.app.getAllUserNames()
     self.player_var = ttk.Combobox(frame, width=w, values=tuple(names))
     self.player_var.current(names.index(app.opt.player))
     self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5)
     #
     widget = ttk.Checkbutton(frame,
                              variable=self.confirm_var,
                              text=_("Confirm quit"))
     widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
     widget = ttk.Checkbutton(frame,
                              variable=self.update_stats_var,
                              text=_("Update statistics and logs"))
     widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
     #  widget = ttk.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)
Ejemplo n.º 37
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(_("&OK"), _("&Cancel")),
                   default=0,
                   padx=10, pady=10,
                   buttonpadx=10, buttonpady=5,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 38
0
 def __init__(self, parent, title, app, player, **kw):
     lines = 25
     #if parent and parent.winfo_screenheight() < 600:
     #    lines = 20
     #
     self.font = app.getFont(self.FONT_TYPE)
     font = tkFont.Font(parent, self.font)
     self.font_metrics = font.metrics()
     self.CHAR_H = self.font_metrics['linespace']
     self.CHAR_W = font.measure('M')
     self.app = app
     #
     self.player = player
     self.title = title
     self.sort_by = 'name'
     self.selected_game = None
     #
     kwdefault(kw, width=self.CHAR_W * 64, height=lines * self.CHAR_H)
     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.top.wm_minsize(200, 200)
     self.button = kw.default
     #
     self.sc = AllGames_StatsDialogScrolledCanvas(top_frame,
                                                  width=kw.width,
                                                  height=kw.height)
     self.sc.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
     #
     self.nodes = {}
     self.canvas = self.sc.canvas
     self.canvas.dialog = self
     bind(self.canvas, "<1>", self.singleClick)
     self.fillCanvas(player, title)
     bbox = self.canvas.bbox("all")
     ##print bbox
     ##self.canvas.config(scrollregion=bbox)
     dx, dy = 4, 0
     self.canvas.config(scrollregion=(-dx, -dy, bbox[2] + dx, bbox[3] + dy))
     self.canvas.xview_moveto(-dx)
     self.canvas.yview_moveto(self.YVIEW)
     #
     focus = self.createButtons(bottom_frame, kw)
     self.mainloop(focus, kw.timeout)
Ejemplo n.º 39
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(_("&OK"), _("&Cancel")),
                   default=-1,
                   resizable=False,
                   separator=False,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 40
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings = ((_("&Info..."), 10), 'sep',
                              _("&Load"), _("&Cancel"),),
                   default=0,
                   resizable=True,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 41
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(_('&OK'),),
                   default=0,
                   image=self.app.gimages.logos[4],
                   separator=True,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 42
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(_('&OK'),),
                   default=0,
                   image=self.app.gimages.logos[4],
                   separator=True,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 43
0
 def __init__(self, parent, title, app, player, **kw):
     lines = 25
     #if parent and parent.winfo_screenheight() < 600:
     #    lines = 20
     #
     self.font = app.getFont(self.FONT_TYPE)
     font = tkFont.Font(parent, self.font)
     self.font_metrics = font.metrics()
     self.CHAR_H = self.font_metrics['linespace']
     self.CHAR_W = font.measure('M')
     self.app = app
     #
     self.player = player
     self.title = title
     self.sort_by = 'name'
     self.selected_game = None
     #
     kwdefault(kw, width=self.CHAR_W*64, height=lines*self.CHAR_H)
     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.top.wm_minsize(200, 200)
     self.button = kw.default
     #
     self.sc = AllGames_StatsDialogScrolledCanvas(top_frame,
                                    width=kw.width, height=kw.height)
     self.sc.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
     #
     self.nodes = {}
     self.canvas = self.sc.canvas
     self.canvas.dialog = self
     bind(self.canvas, "<1>", self.singleClick)
     self.fillCanvas(player, title)
     bbox = self.canvas.bbox("all")
     ##print bbox
     ##self.canvas.config(scrollregion=bbox)
     dx, dy = 4, 0
     self.canvas.config(scrollregion=(-dx,-dy,bbox[2]+dx,bbox[3]+dy))
     self.canvas.xview_moveto(-dx)
     self.canvas.yview_moveto(self.YVIEW)
     #
     focus = self.createButtons(bottom_frame, kw)
     self.mainloop(focus, kw.timeout)
Ejemplo n.º 44
0
 def initKw(self, kw):
     kw = KwStruct(
         kw,
         strings=(_("&OK"), _("&Cancel")),
         default=0,
         padx=10,
         pady=10,
     )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 45
0
 def initKw(self, kw):
     kwdefault(kw,
               strings=(_('&OK'), _('&Solid color...'), _('&Cancel'),),
               default=0,
               resizable=1,
               padx=10, pady=10,
               width=600, height=400,
               )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 46
0
 def initKw(self, kw):
     kwdefault(kw,
               strings=(_("&Load"), _("&Cancel"), _("&Info..."),),
               default=1,
               resizable=1,
               padx=10, pady=10,
               width=600, height=400,
               )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 47
0
 def initKw(self, kw):
     kwdefault(kw,
               strings=(_('&OK'), _('&Solid color...'), _('&Cancel'),),
               default=0,
               resizable=1,
               padx=10, pady=10,
               width=600, height=400,
               )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 48
0
 def initKw(self, kw):
     kw = KwStruct(
         kw,
         strings=(_("&OK"), (_("&Save to file"), 500)),
         default=0,
         width=76 * self.CHAR_W,
         separator=False,
     )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 49
0
 def initKw(self, kw):
     strings=[_("&OK"), _("&Apply"), _("&Cancel"),]
     kw = KwStruct(kw,
                   strings=strings,
                   default=0,
                   padx=10, pady=10,
                   buttonpadx=10, buttonpady=5,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 50
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=((_("&Play this game"), 401),
                            "sep", _("&OK"),
                            (_("&Reset..."), 500)),
                   default=0,
                   separator=False,
     )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 51
0
 def initKw(self, kw):
     kwdefault(kw,
               strings=(_("&Load"), _("&Cancel"), _("&Info..."),),
               default=1,
               resizable=1,
               padx=10, pady=10,
               width=600, height=400,
               )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 52
0
 def initKw(self, kw):
     kw = KwStruct(
         kw,
         strings=((_("&Play this game"), 401), "sep", _("&OK"),
                  (_("&Reset..."), 500)),
         default=0,
         separator=False,
     )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 53
0
 def initKw(self, kw):
     kw = KwStruct(kw,
                   strings=(_("&OK"),
                            (_("&Save to file"), 500)),
                   default=0,
                   width=76*self.CHAR_W,
                   separator=False,
                   )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 54
0
    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)
Ejemplo n.º 55
0
 def initKw(self, kw):
     kwdefault(kw,
               strings=(_('&OK'), _('&Cancel'),),
               default=0,
               #resizable=1,
               padx=10, pady=10,
               #width=600, height=400,
               ##~ buttonpadx=10, buttonpady=5,
               )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 56
0
 def initKw(self, kw):
     kw = KwStruct(
         kw,
         strings=(_("&OK"),
                  (_("&All games..."), 102),
                  (TOP_TITLE+"...", 105),
                  (_("&Reset..."), 302)), default=0,
         image=self.app.gimages.logos[5],
         padx=10, pady=10,
     )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 57
0
    def __init__(self, parent, title, usernames=[], **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)
        #
        listbox = Tkinter.Listbox(top_frame)
        listbox.pack(side='left', fill='both', expand=True)
        scrollbar = Tkinter.Scrollbar(top_frame)
        scrollbar.pack(side='right', fill='y')
        listbox.configure(yscrollcommand=scrollbar.set)
        scrollbar.configure(command=listbox.yview)

        self.username = None
        self.listbox = listbox
        bind(listbox, '<<ListboxSelect>>', self.updateUserName)
        #
        for un in usernames:
            listbox.insert('end', un)
        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
Ejemplo n.º 58
0
 def initKw(self, kw):
     kw = KwStruct(
         kw,
         strings=(_("&OK"),
                  (_("&Save to file"), 202),
                  (_("&Reset all..."), 301),),
         default=0,
         resizable=True,
         padx=10, pady=10,
         # width=900,
     )
     return MfxDialog.initKw(self, kw)
Ejemplo n.º 59
0
    def __init__(self, parent, title, app, player, **kw):

        self.font = app.getFont('default')
        self.tkfont = tkFont.Font(parent, self.font)
        style = ttk.Style(parent)
        heading_font = style.lookup('Heading', 'font')  # treeview heading
        self.heading_tkfont = tkFont.Font(parent, heading_font)
        self.font_metrics = self.tkfont.metrics()

        self.CHAR_H = self.font_metrics['linespace']
        self.CHAR_W = self.tkfont.measure('M')

        kw = self.initKw(kw)
        title = _('Log')
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)

        ##self.selected_game = None

        top_frame, bottom_frame = self.createFrames(kw)
        notebook = ttk.Notebook(top_frame)
        notebook.pack(expand=True, fill='both', padx=10, pady=10)

        self.notebook_tabs = []

        full_frame = FullLogFrame(self, notebook, app, player)
        notebook.add(full_frame, text=_('Full log'))
        self.notebook_tabs.append(full_frame._w)

        session_frame = SessionLogFrame(self, notebook, app, player)
        notebook.add(session_frame, text=_('Session log'))
        self.notebook_tabs.append(session_frame._w)

        notebook.select(LogDialog.SELECTED_TAB)
        ##         bind(notebook, '<<NotebookTabChanged>>', self.tabChanged)

        self.notebook = notebook

        focus = self.createButtons(bottom_frame, kw)
        ##self.tabChanged()               # configure buttons state
        self.mainloop(focus, kw.timeout)