コード例 #1
0
ファイル: test_textview.py プロジェクト: Eyepea/cpython
    def test_view_text_bind_with_button(self):
        def _command():
            self.called = True
            self.view = tv.view_text(root, 'TITLE_TEXT', 'COMMAND', _utest=True)
        button = Button(root, text='BUTTON', command=_command)
        button.invoke()
        self.addCleanup(button.destroy)

        self.assertEqual(self.called, True)
        self.assertEqual(self.view.title(), 'TITLE_TEXT')
        self.assertEqual(self.view.viewframe.textframe.text.get('1.0', '1.end'),
                         'COMMAND')
コード例 #2
0
    def test_view_text_bind_with_button(self):
        def _command():
            self.called = True
            self.view = tv.view_text(root, 'TITLE_TEXT', 'COMMAND', _utest=True)
        button = Button(root, text='BUTTON', command=_command)
        button.invoke()
        self.addCleanup(button.destroy)

        self.assertEqual(self.called, True)
        self.assertEqual(self.view.title(), 'TITLE_TEXT')
        self.assertEqual(self.view.viewframe.textframe.text.get('1.0', '1.end'),
                         'COMMAND')
コード例 #3
0
ファイル: test_textview.py プロジェクト: 1st1/cpython
    def test_view_file_bind_with_button(self):
        def _command():
            self.called = True
            self.view = tv.view_file(root, 'TITLE_FILE', __file__, _utest=True)
        button = Button(root, text='BUTTON', command=_command)
        button.invoke()
        self.addCleanup(button.destroy)

        self.assertEqual(self.called, True)
        self.assertEqual(self.view.title(), 'TITLE_FILE')
        get = self.view.viewframe.textframe.text.get
        with open(__file__) as f:
            self.assertEqual(get('1.0', '1.end'), f.readline().strip())
            f.readline()
            self.assertEqual(get('3.0', '3.end'), f.readline().strip())
コード例 #4
0
ファイル: test_textview.py プロジェクト: adUst0/FixSubs
    def test_view_file_bind_with_button(self):
        def _command():
            self.called = True
            self.view = tv.view_file(root, 'TITLE_FILE', __file__, _utest=True)

        button = Button(root, text='BUTTON', command=_command)
        button.invoke()
        self.addCleanup(button.destroy)

        self.assertEqual(self.called, True)
        self.assertEqual(self.view.title(), 'TITLE_FILE')
        get = self.view.viewframe.textframe.text.get
        with open(__file__) as f:
            self.assertEqual(get('1.0', '1.end'), f.readline().strip())
            f.readline()
            self.assertEqual(get('3.0', '3.end'), f.readline().strip())
コード例 #5
0
    def __init__(self, parentdir: str):
        """\
        Parameters
        ---------
        parentdir (str): The path of the directory where the SymLink will be placed
        """

        self.initDir = Path(parentdir)
        Tk.__init__(self)
        wd = 400
        ht = 100
        self.title("Create Symbolic Link")
        self.attributes('-topmost', 1)
        x = ((self.winfo_screenwidth() - wd) // 2)
        y = ((self.winfo_screenheight() - ht) // 2)
        self.geometry(f'{wd}x{ht}+{x}+{y}')
        self.bind_all('<Escape>', lambda _: self.destroy())

        lbl1 = Label(
            master=self,
            font='Ebrima 12',
            text="Would you like to make a Symlink for a folder or a file?")
        lbl1.place(anchor='center', relx=0.5, rely=0.3)

        folder_btn = Button(master=self,
                            text="Folder",
                            underline=0,
                            command=lambda: self.createLink('folder'),
                            width=10)
        folder_btn.place(anchor='center', relx=0.25, rely=0.66)
        folder_btn.focus_set()
        self.bind_all('<Return>', lambda _: folder_btn.invoke())

        file_btn = Button(master=self,
                          text=" File ",
                          command=lambda: self.createLink('file'),
                          width=10)
        file_btn.place(anchor='center', relx=0.5, rely=0.66)

        cancel_btn = Button(master=self,
                            text="Cancel",
                            command=self.destroy,
                            width=10)
        cancel_btn.place(anchor='center', relx=0.75, rely=0.66)

        self.mainloop()
コード例 #6
0
ファイル: gui.py プロジェクト: jwdafoe/DrvTool
 def show_about(self):
     about = Toplevel(self.master)
     about.title('About {}'.format(self.version[:-5]))
     about.focus()
     about.resizable(0, 0)
     logo_lbl = Label(about, image=self.logo)
     logo_lbl.image = self.logo
     logo_lbl.grid(row=0, column=0, padx='7 11', pady=13, sticky='n')
     about_frame = Frame(about, padding='0 10 10 10')
     about_frame.grid(row=0, column=1)
     Label(about_frame, text=self.version).grid(sticky='w')
     Label(about_frame, text='Developer:  Joel W. Dafoe').grid(pady='6', sticky='w')
     link = Link(about_frame, text='http://cyberdatx.com', foreground='blue', cursor='hand2')
     link.grid(sticky='w')
     link.bind('<Button-1>', lambda e: webbrowser.open('http://cyberdatx.com'))
     Label(about_frame, text=self.description, wraplength=292).grid(columnspan=2, pady=6, sticky='w')
     cls_btn = Button(about_frame, text='OK', command=about.destroy)
     cls_btn.grid(column=1, sticky='e')
     cls_btn.focus()
     about.bind('<Return>', lambda e: cls_btn.invoke())
コード例 #7
0
def bind_button(button: ttk.Button):
    button.bind("<Key-Return>", lambda e: button.invoke())
    button.bind("<KP_Enter>", lambda e: button.invoke())