Пример #1
0
 def __init__(self, parent, rootnodes, **kw):
     kw['bd'] = 0
     kw['bg'] = 'white'
     MfxScrolledCanvas.__init__(self, parent, **kw)
     #
     self.rootnodes = rootnodes
     self.updateNodesWithTree(self.rootnodes, self)
     self.selection_key = None
     self.nodes = {}
     self.keys = {}
     #
     self.style = self.Style()
     # self.style.text_normal_fg = self.canvas.cget("insertbackground")
     # self.style.text_normal_fg = \
     #   self.canvas.option_get('foreground', '') or \
     #   self.canvas.cget("insertbackground")
     # self.style.text_normal_bg = self.canvas.option_get(
     #   'background', self.canvas.cget("background"))
     #
     from pysollib.options import calcCustomMouseButtonsBinding
     bind(self.canvas,
          calcCustomMouseButtonsBinding("<ButtonPress-{mouse_button1}>"),
          self.singleClick)
     bind(self.canvas,
          calcCustomMouseButtonsBinding("<Double-Button-{mouse_button1}>"),
          self.doubleClick)
     # bind(self.canvas,
     # calcCustomMouseButtonsBinding(
     # "<ButtonRelease-{mouse_button1}>"), xxx)
     self.pack(fill='both', expand=True)
Пример #2
0
    def __init__(self, app, parent, title, **kw):
        self._url = kw['url']
        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.button = kw.default
        frame = ttk.Frame(top_frame)
        frame.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
        msg = ttk.Label(frame,
                        text=kw.text,
                        justify=kw.justify,
                        width=kw.width)
        msg.pack(fill='both', expand=True)

        # font_name = msg.lookup('TLabel', 'font')
        font_name = 'TkDefaultFont'
        font = tkinter_font.Font(parent, name=font_name, exists=True)
        font = font.copy()
        font.configure(underline=True)
        url_label = ttk.Label(frame,
                              text=kw.url,
                              font=font,
                              foreground='blue',
                              cursor='hand2')
        url_label.pack()
        from pysollib.options import calcCustomMouseButtonsBinding
        url_label.bind(calcCustomMouseButtonsBinding('<{mouse_button1}>'),
                       self._urlClicked)
        #
        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
Пример #3
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 = tkinter_font.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
     from pysollib.options import calcCustomMouseButtonsBinding
     bind(self.canvas, calcCustomMouseButtonsBinding("<{mouse_button1}>"),
          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)
Пример #4
0
 def anchor_end(self):
     if self.anchor:
         url = self.anchor[0]
         tag = "href_" + url
         self.text.tag_add(tag, self.anchor_mark, "insert")
         from pysollib.options import calcCustomMouseButtonsBinding
         self.text.tag_bind(
             tag, calcCustomMouseButtonsBinding("<{mouse_button1}>"),
             self.createCallback(url))
         self.text.tag_bind(tag, "<Enter>",
                            lambda e: self.anchor_enter(url))
         self.text.tag_bind(tag, "<Leave>", self.anchor_leave)
         fg = 'blue'
         u = self.viewer.normurl(url, with_protocol=False)
         if u in self.viewer.visited_urls:
             fg = '#660099'
         self.text.tag_config(tag, foreground=fg, underline=1)
         self.anchor = None
Пример #5
0
 def _bind2sep(sep):
     sep.bind(calcCustomMouseButtonsBinding("<{mouse_button1}>"),
              self.clickHandler)
     sep.bind(calcCustomMouseButtonsBinding("<{mouse_button3}>"),
              self.rightclickHandler)
Пример #6
0
    def __init__(self,
                 top,
                 menubar,
                 dir,
                 size=0,
                 relief='flat',
                 compound='none'):
        self.top = top
        self.menubar = menubar
        self.side = -1
        self._tooltips = []
        self._widgets = []
        self.dir = dir
        self.size = size
        self.compound = compound
        self.orient = 'horizontal'
        self.button_pad = 2
        #
        self.frame = tkinter.Frame(top,
                                   relief=TkSettings.toolbar_relief,
                                   bd=TkSettings.toolbar_borderwidth)

        from pysollib.options import calcCustomMouseButtonsBinding

        def _bind2sep(sep):
            sep.bind(calcCustomMouseButtonsBinding("<{mouse_button1}>"),
                     self.clickHandler)
            sep.bind(calcCustomMouseButtonsBinding("<{mouse_button3}>"),
                     self.rightclickHandler)

        for label, f, t in (
            (n_("New"), self.mNewGame, _("New game")),
            (n_("Restart"), self.mRestart, _("Restart the\ncurrent game")),
            (None, None, None),
            (n_("Open"), self.mOpen, _("Open a\nsaved game")),
            (n_("Save"), self.mSave, _("Save game")),
            (None, None, None),
            (n_("Undo"), self.mUndo, _("Undo last move")),
            (n_("Redo"), self.mRedo, _("Redo last move")),
            (n_("Autodrop"), self.mDrop, _("Auto drop cards")),
            (n_("Shuffle"), self.mShuffle, _("Shuffle tiles")),
            (n_("Pause"), self.mPause, _("Pause game")),
            (None, None, None),
            (n_("Statistics"), self.mPlayerStats, _("View statistics")),
            (n_("Rules"), self.mHelpRules, _("Rules for this game")),
            (None, None, None),
            (n_("Quit"), self.mQuit, _("Quit %s") % TITLE),
        ):
            if label is None:
                sep = self._createSeparator()
                _bind2sep(sep)
            elif label == 'Pause':
                self._createButton(label, f, check=True, tooltip=t)
            else:
                self._createButton(label, f, tooltip=t)
        self.pause_button.config(variable=menubar.tkopt.pause)

        sep = self._createFlatSeparator()
        _bind2sep(sep)
        self._createLabel("player",
                          label=n_('Player'),
                          tooltip=_("Player options"))
        #
        self.player_label.bind(
            calcCustomMouseButtonsBinding("<{mouse_button1}>"),
            self.mOptPlayerOptions)
        # self.player_label.bind("<3>",self.mOptPlayerOptions)
        self.popup = MfxMenu(master=None, label=n_('Toolbar'), tearoff=0)
        createToolbarMenu(menubar, self.popup)
        _bind2sep(self.frame)
        #
        self.setCompound(compound, force=True)