Python tkinter.ttk.Button() Examples

The following are 30 code examples of tkinter.ttk.Button(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter.ttk , or try the search function .
Example #1
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 7 votes vote down vote up
def show_login_screen(self):
        self.login_frame = ttk.Frame(self)

        username_label = ttk.Label(self.login_frame, text="Username")
        self.username_entry = ttk.Entry(self.login_frame)

        real_name_label = ttk.Label(self.login_frame, text="Real Name")
        self.real_name_entry = ttk.Entry(self.login_frame)

        login_button = ttk.Button(self.login_frame, text="Login", command=self.login)
        create_account_button = ttk.Button(self.login_frame, text="Create Account", command=self.create_account)

        username_label.grid(row=0, column=0, sticky='e')
        self.username_entry.grid(row=0, column=1)

        real_name_label.grid(row=1, column=0, sticky='e')
        self.real_name_entry.grid(row=1, column=1)

        login_button.grid(row=2, column=0, sticky='e')
        create_account_button.grid(row=2, column=1)

        for i in range(3):
            tk.Grid.rowconfigure(self.login_frame, i, weight=1)
            tk.Grid.columnconfigure(self.login_frame, i, weight=1)

        self.login_frame.pack(fill=tk.BOTH, expand=1) 
Example #2
Source File: program9.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):
        self.frame = ttk.Frame(master, width = 100, height = 100)   # frame height and width are in pixel
        self.frame.pack()
        self.frame.config(relief = tk.RAISED)   # to define frame boarder
        self.button = ttk.Button(self.frame, text = 'Click for Magic')
        self.button.config(command = self.performMagic)
        self.button.grid()  # use grid geometry manager
        self.frame.config(padding = (30,15))
        
        self.lbfrm = ttk.LabelFrame(master, width = 100, height = 100)
        self.lbfrm.config(padding = (30, 15))
        self.lbfrm.config(text = "Magic Below")
        self.lbfrm.pack()
        self.label = ttk.Label(self.lbfrm, text = "Waiting for Magic")
        self.label.grid() 
Example #3
Source File: smilieselect.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self, master, **kwargs):
        super().__init__(**kwargs)
        self.master = master
        self.transient(master)
        self.position_window()

        smilie_files = [file for file in os.listdir(self.smilies_dir) if file.endswith(".png")]

        self.smilie_images = []

        for file in smilie_files:
            full_path = os.path.join(self.smilies_dir, file)
            image = tk.PhotoImage(file=full_path)
            self.smilie_images.append(image)

        for index, file in enumerate(self.smilie_images):
            row, col = divmod(index, 3)
            button = ttk.Button(self, image=file, command=lambda s=file: self.insert_smilie(s))
            button.grid(row=row, column=col, sticky='nsew')

        for i in range(3):
            tk.Grid.columnconfigure(self, i, weight=1)
            tk.Grid.rowconfigure(self, i, weight=1) 
Example #4
Source File: smilieselect.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self, master, **kwargs):
        super().__init__(**kwargs)
        self.master = master
        self.transient(master)
        self.position_window()

        smilie_files = [file for file in os.listdir(self.smilies_dir) if file.endswith(".png")]

        self.smilie_images = []

        for file in smilie_files:
            full_path = os.path.join(self.smilies_dir, file)
            image = tk.PhotoImage(file=full_path)
            self.smilie_images.append(image)

        for index, file in enumerate(self.smilie_images):
            row, col = divmod(index, 3)
            button = ttk.Button(self, image=file, command=lambda s=file: self.insert_smilie(s))
            button.grid(row=row, column=col, sticky='nsew')

        for i in range(3):
            tk.Grid.columnconfigure(self, i, weight=1)
            tk.Grid.rowconfigure(self, i, weight=1) 
Example #5
Source File: avatarwindow.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self, master):
        super().__init__()

        self.master = master
        self.transient(master)

        self.title("Change Avatar")
        self.geometry("350x200")

        self.image_file_types = [
            ("Png Images", ("*.png", "*.PNG")),
        ]

        self.current_avatar_image = tk.PhotoImage(file=avatar_file_path)

        self.current_avatar = ttk.Label(self, image=self.current_avatar_image)
        choose_file_button = ttk.Button(self, text="Choose File", command=self.choose_image)

        self.current_avatar.pack()
        choose_file_button.pack() 
Example #6
Source File: smilieselect.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self, master, **kwargs):
        super().__init__(**kwargs)
        self.master = master
        self.transient(master)
        self.position_window()

        smilie_files = [file for file in os.listdir(self.smilies_dir) if file.endswith(".png")]

        self.smilie_images = []

        for file in smilie_files:
            full_path = os.path.join(self.smilies_dir, file)
            image = tk.PhotoImage(file=full_path)
            self.smilie_images.append(image)

        for index, file in enumerate(self.smilie_images):
            row, col = divmod(index, 3)
            button = ttk.Button(self, image=file, command=lambda s=file: self.insert_smilie(s))
            button.grid(row=row, column=col, sticky='nsew')

        for i in range(3):
            tk.Grid.columnconfigure(self, i, weight=1)
            tk.Grid.rowconfigure(self, i, weight=1) 
Example #7
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def load_friends(self):
        all_users = self.requester.get_all_users()

        for user in all_users:
            if user['username'] != self.username:
                friend_frame = ttk.Frame(self.canvas_frame)

                profile_photo = tk.PhotoImage(file="images/avatar.png")
                profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
                profile_photo_label.image = profile_photo

                friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W)

                message_this_friend = partial(self.open_chat_window, username=user["username"], real_name=user["real_name"])

                message_button = ttk.Button(friend_frame, text="Chat", command=message_this_friend)

                profile_photo_label.pack(side=tk.LEFT)
                friend_name.pack(side=tk.LEFT)
                message_button.pack(side=tk.RIGHT)

                friend_frame.pack(fill=tk.X, expand=1) 
Example #8
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def show_login_screen(self):
        self.login_frame = ttk.Frame(self)

        username_label = ttk.Label(self.login_frame, text="Username")
        self.username_entry = ttk.Entry(self.login_frame)
        self.username_entry.focus_force()

        real_name_label = ttk.Label(self.login_frame, text="Real Name")
        self.real_name_entry = ttk.Entry(self.login_frame)

        login_button = ttk.Button(self.login_frame, text="Login", command=self.login)
        create_account_button = ttk.Button(self.login_frame, text="Create Account", command=self.create_account)

        username_label.grid(row=0, column=0, sticky='e')
        self.username_entry.grid(row=0, column=1)

        real_name_label.grid(row=1, column=0, sticky='e')
        self.real_name_entry.grid(row=1, column=1)

        login_button.grid(row=2, column=0, sticky='e')
        create_account_button.grid(row=2, column=1)

        for i in range(3):
            tk.Grid.rowconfigure(self.login_frame, i, weight=1)
            tk.Grid.columnconfigure(self.login_frame, i, weight=1)

        self.login_frame.pack(fill=tk.BOTH, expand=1)

        self.login_event = self.bind("<Return>", self.login) 
Example #9
Source File: annotation_gui.py    From SEM with MIT License 6 votes vote down vote up
def load_pipeline(self, event=None):
        top = tkinter.Toplevel()
        master_selector = SemTkMasterSelector(top, os.path.join(sem.SEM_DATA_DIR, "resources"))
        lang_selector = SemTkLangSelector(top, os.path.join(sem.SEM_DATA_DIR, "resources"))
        lang_selector.master_selector = master_selector
        vars_cur_row = 0
        vars_cur_row, _ = lang_selector.grid(row=vars_cur_row, column=0)
        vars_cur_row, _ = master_selector.grid(row=vars_cur_row, column=0)
        
        def cancel(event=None):
            if self.pipeline is not None:
                self.tag_document_btn.configure(state=tkinter.NORMAL)
            top.destroy()
        def ok(event=None):
            path = master_selector.workflow()
            pipeline, _, _, _ = sem.modules.tagger.load_master(path)
            self.pipeline = pipeline
            cancel()
        
        ok_btn = ttk.Button(top, text="load workflow", command=ok)
        ok_btn.grid(row=vars_cur_row, column=0)
        cancel_btn = ttk.Button(top, text="cancel", command=cancel)
        cancel_btn.grid(row=vars_cur_row, column=1) 
Example #10
Source File: program13.py    From python-gui-demos with MIT License 6 votes vote down vote up
def tagDemo(self):
        if self.btn9['text']=='Create tag named \'myTag\' at line 2':
            self.btn9.config(text = 'Remove Tag')
            self.text.tag_add('myTag', '2.0', '2.0 lineend')
            
            self.btn10 = ttk.Button(self.master, text = 'Change myTag background to yellow', command = self.tagbgyellow)
            self.btn10.pack()
            
            self.btn11 = ttk.Button(self.master, text = 'Remove tag from 1st word of line 2', command = self.tagrm21word)
            self.btn11.pack()
            
            self.btn12 = ttk.Button(self.master, text = 'myTag Span', command = self.getTagSpan)
            self.btn12.pack()
            
            self.btn13 = ttk.Button(self.master, text = 'Show all Tags in Text widget', command = self.displayAllTags)
            self.btn13.pack()
            
        else:
            self.btn9.config(text = 'Create tag named \'myTag\' at line 2')
            self.text.tag_delete('myTag')
            self.btn10.destroy()
            self.btn11.destroy()
            self.btn12.destroy()
            self.btn13.destroy() 
Example #11
Source File: program4.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):
        self.button = ttk.Button(master, text = 'Click me')
        self.button.pack()
        self.button.config(command = self.buttonfunc)          # configure a command for button click
        
        self.btn1 = ttk.Button(master, text = 'Click on \'Click me\'', command = self.invokebutton)
        self.btn1.pack()
        
        self.btn2 = ttk.Button(master, text = 'Disable \'Click me\'', command = self.disableButton)
        self.btn2.pack()
        
        self.btn3 = ttk.Button(master, text = 'Enable \'Click me\'', command = self.enableButton)
        self.btn3.pack()
        
        self.btn4 = ttk.Button(master, text = 'Query state of \'Click me\'', command = self.queryButtonState)
        self.btn4.pack()
        
        self.button.img  = tk.PhotoImage(file = 'simple_gif.gif')
        self.button.img = self.button.img.subsample(10, 10) # take every 5th pixel in x and y direction of image
        
        self.btn5 = ttk.Button(master, text = 'Add image to \'Click me\'', command = self.addImage)
        self.btn5.pack()
        
        self.label = ttk.Label(master, text = 'No button pressed yet.')
        self.label.pack() 
Example #12
Source File: program3.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):     # constructor method
        # define list of label texts
        self.greet_list = ('Hello, World! This is python GUI.', \
                           'Hello, This is Python GUI. Sadly, I was made to say Hello only. I will love to say so much more.')
        
        # creat label as a child of root window with some text.
        self.label = ttk.Label(master, text = self.greet_list[0])
        
        self.btn = ttk.Button(master, text = 'Greet Again', command = self.handle_text) # create a button
        
        # store image in the label obj to keep it in the scope as 
        # long as label is displayed and to avoid getting the image getting garbage collected
        imgpath = 'simple_gif.gif'                                      # path of the image
        self.label.img = tk.PhotoImage(file = imgpath)                  # read_image :: saving image within label_object to prevent its garbage collection
        self.label.config(image = self.label.img)                       # display image in label widget
        self.label.config(compound = 'left')                            # to display image in left of text
        
        self.label.pack()                                               # pack label to the window with pack() geometry method of Label
        self.btn.pack()
        
        self.label.config(wraplength = 200)                             # specify wraplength of text in label
        self.label.config(justify = tk.CENTER)                          # justify text in label to (CENTER, RIGHT or LEFT)
        self.label.config(foreground = 'blue', background = 'yellow')   # insert font color (foreground) and background color
        self.label.config(font = ('Times', 10, 'bold'))                 # font = (font_name, font_size, font_type) 
Example #13
Source File: tgc_gui.py    From TGC-Designer-Tools with Apache License 2.0 6 votes vote down vote up
def combineAction():
    global course_json
    other_course_dir = tk.filedialog.askdirectory(initialdir = ".", title = "Select second course directory")

    if other_course_dir:
        drawPlaceholder()
        course1_json = copy.deepcopy(course_json) # Make copy so this isn't "permanent" in memory
        course2_json = tgc_tools.get_course_json(other_course_dir)

        course1_json = tgc_tools.merge_courses(course1_json, course2_json)
        drawCourse(course1_json)

        popup = tk.Toplevel()
        popup.geometry("400x400")
        popup.wm_title("Confirm course merge?")
        label = ttk.Label(popup, text="Confirm course merge?")
        label.pack(side="top", fill="x", pady=10)
        B1 = ttk.Button(popup, text="Yes, Merge", command = partial(confirmCourse, popup, course1_json))
        B1.pack()
        B2 = ttk.Button(popup, text="No, Abandon Merge", command = partial(confirmCourse, popup, None))
        B2.pack()
        popup.mainloop() 
Example #14
Source File: gui.py    From skan with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create_buttons_frame(self, parent):
        buttons = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
        buttons.grid(sticky='nsew')
        actions = [
            ('Choose config', self.choose_config_file),
            ('Choose files', self.choose_input_files),
            ('Choose output folder', self.choose_output_folder),
            ('Run', lambda: asyncio.ensure_future(self.run()))
        ]
        for col, (action_name, action) in enumerate(actions):
            button = ttk.Button(buttons, text=action_name,
                                command=action)
            button.grid(row=0, column=col) 
Example #15
Source File: Dock.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def __create_widgets(self):
        self.dockFrame = ttk.Frame(self, relief=tk.RAISED, padding=PAD)
        self.dockLeftButton = ttk.Button(self.dockFrame,
                image=self.images[DOCKLEFT], style="Toolbutton",
                command=self.dock_left)
        TkUtil.Tooltip.Tooltip(self.dockLeftButton, text="Dock Left")
        self.dockRightButton = ttk.Button(self.dockFrame,
                image=self.images[DOCKRIGHT], style="Toolbutton",
                command=self.dock_right)
        TkUtil.Tooltip.Tooltip(self.dockRightButton, text="Dock Right")
        self.dockLabel = ttk.Label(self.dockFrame, text=self.title,
                anchor=tk.CENTER)
        TkUtil.Tooltip.Tooltip(self.dockLabel, text="Drag and drop to "
                "dock elsewhere or to undock")
        self.undockButton = ttk.Button(self.dockFrame,
                image=self.images[UNDOCK], style="Toolbutton",
                command=self.undock)
        TkUtil.Tooltip.Tooltip(self.undockButton, text="Undock")
        self.hideButton = ttk.Button(self.dockFrame,
                image=self.images[HIDE], style="Toolbutton",
                command=lambda *args: self.visible.set(False))
        TkUtil.Tooltip.Tooltip(self.hideButton, text="Hide")
        self.create_widgets() 
Example #16
Source File: program11.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):
        self.master = master
        self.panedWindow = ttk.Panedwindow(self.master, orient = tk.HORIZONTAL)  # orient panes horizontally next to each other
        self.panedWindow.pack(fill = tk.BOTH, expand = True)    # occupy full master window and enable expand property
        
        self.frame1 = ttk.Frame(self.panedWindow, width = 100, height = 300, relief = tk.SUNKEN)
        self.frame2 = ttk.Frame(self.panedWindow, width = 400, height = 400, relief = tk.SUNKEN)
        
        self.panedWindow.add(self.frame1, weight = 1)
        self.panedWindow.add(self.frame2, weight = 3)
        
        self.button = ttk.Button(self.frame1, text = 'Add frame in Paned Window', command = self.AddFrame)
        self.button.pack() 
Example #17
Source File: data_entry_app.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, parent, label='', input_class=ttk.Entry,
                 input_var=None, input_args=None, label_args=None,
                 **kwargs):
        super().__init__(parent, **kwargs)
        input_args = input_args or {}
        label_args = label_args or {}
        self.variable = input_var

        if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton):
            input_args["text"] = label
            input_args["variable"] = input_var
        else:
            self.label = ttk.Label(self, text=label, **label_args)
            self.label.grid(row=0, column=0, sticky=(tk.W + tk.E))
            input_args["textvariable"] = input_var

        self.input = input_class(self, **input_args)
        self.input.grid(row=1, column=0, sticky=(tk.W + tk.E))
        self.columnconfigure(0, weight=1)
        self.error = getattr(self.input, 'error', tk.StringVar())
        self.error_label = ttk.Label(self, textvariable=self.error)
        self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E)) 
Example #18
Source File: data_entry_app.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.title("ABQ Data Entry Application")
        self.resizable(width=False, height=False)

        ttk.Label(
            self,
            text="ABQ Data Entry Application",
            font=("TkDefaultFont", 16)
        ).grid(row=0)


        self.recordform = DataRecordForm(self)
        self.recordform.grid(row=1, padx=10)

        self.savebutton = ttk.Button(self, text="Save", command=self.on_save)
        self.savebutton.grid(sticky="e", row=2, padx=10)

        # status bar
        self.status = tk.StringVar()
        self.statusbar = ttk.Label(self, textvariable=self.status)
        self.statusbar.grid(sticky="we", row=3, padx=10)

        self.records_saved = 0 
Example #19
Source File: application.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.title("ABQ Data Entry Application")
        self.resizable(width=False, height=False)

        ttk.Label(
            self,
            text="ABQ Data Entry Application",
            font=("TkDefaultFont", 16)
        ).grid(row=0)


        self.recordform = v.DataRecordForm(self, m.CSVModel.fields)
        self.recordform.grid(row=1, padx=10)

        self.savebutton = ttk.Button(self, text="Save", command=self.on_save)
        self.savebutton.grid(sticky="e", row=2, padx=10)

        # status bar
        self.status = tk.StringVar()
        self.statusbar = ttk.Label(self, textvariable=self.status)
        self.statusbar.grid(sticky="we", row=3, padx=10)

        self.records_saved = 0 
Example #20
Source File: data_entry_app.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.title("ABQ Data Entry Application")
        self.resizable(width=False, height=False)

        ttk.Label(
            self,
            text="ABQ Data Entry Application",
            font=("TkDefaultFont", 16)
        ).grid(row=0)

        self.recordform = DataRecordForm(self)
        self.recordform.grid(row=1, padx=10)

        self.savebutton = ttk.Button(self, text="Save", command=self.on_save)
        self.savebutton.grid(sticky=tk.E, row=2, padx=10)

        # status bar
        self.status = tk.StringVar()
        self.statusbar = ttk.Label(self, textvariable=self.status)
        self.statusbar.grid(sticky=(tk.W + tk.E), row=3, padx=10)

        self.records_saved = 0 
Example #21
Source File: better_hello_tkinter.py    From Python-GUI-Programming-with-Tkinter with MIT License 6 votes vote down vote up
def __init__(self, parent, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)

        self.name = tk.StringVar()
        self.hello_string = tk.StringVar()
        self.hello_string.set("Hello World")

        name_label = ttk.Label(self, text="Name:")
        name_entry = ttk.Entry(self, textvariable=self.name)
        ch_button = ttk.Button(self, text="Change", command=self.on_change)
        hello_label = ttk.Label(self, textvariable=self.hello_string,
            font=("TkDefaultFont", 64), wraplength=600)

        # Layout form
        name_label.grid(row=0, column=0, sticky=tk.W)
        name_entry.grid(row=0, column=1, sticky=(tk.W + tk.E))
        ch_button.grid(row=0, column=2, sticky=tk.E)
        hello_label.grid(row=1, column=0, columnspan=3)
        self.columnconfigure(1, weight=1) 
Example #22
Source File: extended_pyGISS.py    From pyGISS with MIT License 6 votes vote down vote up
def __init__(self, controller):
        super().__init__(controller, bg='white', width=1300, height=800)
        self.controller = controller
        self.node_id_to_node = {}
        self.drag_item = None
        self.start_position = [None]*2
        self.start_pos_main_node = [None]*2
        self.dict_start_position = {}
        self.selected_nodes = set()
        self.filepath = None
        self.proj = 'Mercator'
        self.ratio, self.offset = 1, (0, 0)
        self.bind('<MouseWheel>', self.zoomer)
        self.bind('<Button-4>', lambda e: self.zoomer(e, 1.3))
        self.bind('<Button-5>', lambda e: self.zoomer(e, 0.7))
        self.bind('<ButtonPress-3>', lambda e: self.scan_mark(e.x, e.y))
        self.bind('<B3-Motion>', lambda e: self.scan_dragto(e.x, e.y, gain=1))
        self.bind('<Enter>', self.drag_and_drop, add='+')
        self.bind('<ButtonPress-1>', self.start_point_select_objects, add='+')
        self.bind('<B1-Motion>', self.rectangle_drawing)
        self.bind('<ButtonRelease-1>', self.end_point_select_nodes, add='+')
        self.tag_bind('node', '<Button-1>', self.find_closest_node)
        self.tag_bind('node', '<B1-Motion>', self.node_motion) 
Example #23
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_toolbar(self):
        self.toolbar = ttk.Frame(self.master)
        newButton = ttk.Button(self.toolbar, text=NEW, takefocus=False,
                image=self.images[NEW], command=self.board.new_game)
        TkUtil.Tooltip.Tooltip(newButton, text="New Game")
        zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
        self.zoomSpinbox = Spinbox(self.toolbar,
                textvariable=self.zoom, from_=Board.MIN_ZOOM,
                to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=3,
                justify=tk.RIGHT, validate="all")
        self.zoomSpinbox.config(validatecommand=(
                self.zoomSpinbox.register(self.validate_int), "%P"))
        TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
        self.shapeCombobox = ttk.Combobox(self.toolbar, width=8,
                textvariable=self.shapeName, state="readonly",
                values=sorted(Shapes.ShapeForName.keys()))
        TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
        TkUtil.add_toolbar_buttons(self.toolbar, (newButton, None,
                zoomLabel, self.zoomSpinbox, self.shapeCombobox))
        self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board) 
Example #24
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_edit_toolbar(self):
        settings = TkUtil.Settings.Data
        self.editToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
        self.editToolbar.text = EDIT_TOOLBAR
        self.editToolbar.underline = 0
        menuButton = ttk.Button(self.editToolbar,
                text="Edit Toolbar Menu", 
                image=self.toolbarImages[TOOLBARMENU],
                command=self.toolbar_menu)
        TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
        TkUtil.Tooltip.Tooltip(menuButton, text="Edit Toolbar Menu")
        self.undoButton = ttk.Button(self.editToolbar,
                text=UNDO, image=self.toolbarImages[UNDO],
                command=self.editor.edit_undo)
        TkUtil.Tooltip.Tooltip(self.undoButton, text=UNDO)
        self.redoButton = ttk.Button(self.editToolbar,
                text=REDO, image=self.toolbarImages[REDO],
                command=self.editor.edit_redo)
        TkUtil.Tooltip.Tooltip(self.redoButton, text=REDO)
        self.copyButton = ttk.Button(self.editToolbar,
                text=COPY, image=self.toolbarImages[COPY],
                command=self.editor.text.event_generate("<<Copy>>"))
        TkUtil.Tooltip.Tooltip(self.copyButton, text=COPY)
        self.cutButton = ttk.Button(self.editToolbar, text=CUT,
                image=self.toolbarImages[CUT],
                command=self.editor.text.event_generate("<<Cut>>"))
        TkUtil.Tooltip.Tooltip(self.cutButton, text=CUT)
        self.pasteButton = ttk.Button(self.editToolbar, text=PASTE,
                image=self.toolbarImages[PASTE],
                command=self.editor.text.event_generate("<<Paste>>"))
        TkUtil.Tooltip.Tooltip(self.pasteButton, text=PASTE)
        self.findButton = ttk.Button(self.editToolbar,
                text=FIND, image=self.toolbarImages[FIND],
                command=self.find)
        TkUtil.Tooltip.Tooltip(self.findButton, text=FIND)
        TkUtil.add_toolbar_buttons(self.editToolbar, (menuButton,
                self.undoButton, self.redoButton, None, self.copyButton,
                self.cutButton, self.pasteButton, None, self.findButton))
        self.toolbars.append(self.editToolbar) 
Example #25
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_file_toolbar(self):
        settings = TkUtil.Settings.Data
        self.fileToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
        self.fileToolbar.text = FILE_TOOLBAR
        self.fileToolbar.underline = 0
        menuButton = ttk.Button(self.fileToolbar,
                text="File Toolbar Menu", 
                image=self.toolbarImages[TOOLBARMENU],
                command=self.toolbar_menu)
        TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
        TkUtil.Tooltip.Tooltip(menuButton, text="File Toolbar Menu")
        newButton = ttk.Button(self.fileToolbar, text=NEW,
                image=self.toolbarImages[NEW], command=self.new)
        TkUtil.Tooltip.Tooltip(newButton, text="New Document")
        openButton = ttk.Button(self.fileToolbar, text=OPEN,
                image=self.toolbarImages[OPEN], command=self.open)
        TkUtil.Tooltip.Tooltip(openButton, text="Open Document")
        self.saveButton = ttk.Button(self.fileToolbar, text=SAVE,
                image=self.toolbarImages[SAVE], command=self.save)
        TkUtil.Tooltip.Tooltip(self.saveButton, text="Save Document")
        preferencesButton = ttk.Button(self.fileToolbar,
                text=PREFERENCES, image=self.toolbarImages[PREFERENCES],
                command=self.preferences)
        TkUtil.Tooltip.Tooltip(preferencesButton, text=PREFERENCES)
        TkUtil.add_toolbar_buttons(self.fileToolbar, (menuButton,
                newButton, openButton, self.saveButton, None,
                preferencesButton))
        self.toolbars.append(self.fileToolbar) 
Example #26
Source File: main.py    From Bitcoin-Trading-Client with GNU General Public License v2.0 5 votes vote down vote up
def addTopIndicator(what):
    global topIndicator
    global DatCounter

    if DataPace == "tick":
        popupmsg("Indicators in Tick Data not available, choose 1 minute tf if you want short term.")

    if what == "none":
        topIndicator = what
        DatCounter = 9000

    elif what == "rsi":
        rsiQ = tk.Tk()
        rsiQ.wm_title("Periods?")
        label = ttk.Label(rsiQ, text="Choose how many periods you want each RSI calculation to consider.\nThese periods are contingent on your current time settings on the chart. 1 period = 1 OHLC candlestick.", font=NORM_FONT)
        label.pack(side="top", fill="x", pady=10)

        e = ttk.Entry(rsiQ)
        e.insert(0,14)
        e.pack()
        e.focus_set()

        def callback():
            periods = (e.get())
            group = []
            group.append("rsi")
            group.append(periods)
            topIndicator = group
            DatCounter = 9000
            print("set top indicator to",group)
            rsiQ.destroy()
        
        b = ttk.Button(rsiQ, text="Submit", width=10, command=callback)
        b.pack()

        tk.mainloop()

    elif what == "macd":
        topIndicator = "macd"
        DatCounter = 9000 
Example #27
Source File: main.py    From Bitcoin-Trading-Client with GNU General Public License v2.0 5 votes vote down vote up
def addBottomIndicator(what):
    global bottomIndicator
    global DatCounter

    if DataPace == "tick":
        popupmsg("Indicators in Tick Data not available, choose 1 minute tf if you want short term.")

    if what == "none":
        bottomIndicator = what
        DatCounter = 9000

    elif what == "rsi":
        rsiQ = tk.Tk()
        rsiQ.wm_title("Periods?")
        label = ttk.Label(rsiQ, text="Choose how many periods you want each RSI calculation to consider.\nThese periods are contingent on your current time settings on the chart. 1 period = 1 OHLC candlestick.", font=NORM_FONT)
        label.pack(side="top", fill="x", pady=10)

        e = ttk.Entry(rsiQ)
        e.insert(0,14)
        e.pack()
        e.focus_set()

        def callback():
            periods = (e.get())
            group = []
            group.append("rsi")
            group.append(periods)
            bottomIndicator = group
            DatCounter = 9000
            print("set top indicator to",group)
            rsiQ.destroy()
        
        b = ttk.Button(rsiQ, text="Submit", width=10, command=callback)
        b.pack()

        tk.mainloop()

    elif what == "macd":
        bottomIndicator = "macd"
        DatCounter = 9000 
Example #28
Source File: widgets.py    From Python-GUI-Programming-with-Tkinter with MIT License 5 votes vote down vote up
def __init__(self, parent, label='', input_class=None,
                 input_var=None, input_args=None, label_args=None,
                 field_spec=None, **kwargs):
        super().__init__(parent, **kwargs)
        input_args = input_args or {}
        label_args = label_args or {}
        if field_spec:
            field_type = field_spec.get('type', FT.string)
            input_class = input_class or self.field_types.get(field_type)[0]
            var_type = self.field_types.get(field_type)[1]
            self.variable = input_var if input_var else var_type()
            # min, max, increment
            if 'min' in field_spec and 'from_' not in input_args:
                input_args['from_'] = field_spec.get('min')
            if 'max' in field_spec and 'to' not in input_args:
                input_args['to'] = field_spec.get('max')
            if 'inc' in field_spec and 'increment' not in input_args:
                input_args['increment'] = field_spec.get('inc')
            # values
            if 'values' in field_spec and 'values' not in input_args:
                input_args['values'] = field_spec.get('values')
        else:
            self.variable = input_var

        if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton):
            input_args["text"] = label
            input_args["variable"] = self.variable
        else:
            self.label = ttk.Label(self, text=label, **label_args)
            self.label.grid(row=0, column=0, sticky=(tk.W + tk.E))
            input_args["textvariable"] = self.variable

        self.input = input_class(self, **input_args)
        self.input.grid(row=1, column=0, sticky=(tk.W + tk.E))
        self.columnconfigure(0, weight=1)
        self.error = getattr(self.input, 'error', tk.StringVar())
        self.error_label = ttk.Label(self, textvariable=self.error)
        self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E)) 
Example #29
Source File: Find.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_widgets(self):
        self.findLabel = TkUtil.Label(self, text="Find:", underline=1)
        self.findEntry = ttk.Entry(self, width=25)
        self.replaceLabel = TkUtil.Label(self, text="Replace:",
                underline=1)
        self.replaceEntry = ttk.Entry(self, width=25)
        self.caseSensitiveCheckbutton = TkUtil.Checkbutton(self,
                text="Case Sensitive", underline=5,
                variable=self.caseSensitive)
        self.wholeWordsCheckbutton = TkUtil.Checkbutton(self,
                text="Whole Words", underline=0,
                variable=self.wholeWords)
        self.findButton = TkUtil.Button(self, text="Find", underline=0,
                command=self.find, default=tk.ACTIVE, state=tk.DISABLED)
        self.replaceButton = TkUtil.Button(self, text="Replace",
                underline=0, command=self.replace, state=tk.DISABLED)
        self.closeButton = TkUtil.Button(self, text="Close", underline=0,
                command=self.close)
        if TkUtil.x11():
            self.extendButton = TkUtil.ToggleButton(self, text="Extend",
                    underline=1, command=self.toggle_extend)
        else:
            self.extendButton = ttk.Button(self, text="Extend",
                    underline=1, command=self.toggle_extend,
                    image=self.images[UNEXTEND], compound=tk.LEFT)
        self.extensionWidgets = (self.replaceLabel, self.replaceEntry,
                self.replaceButton) 
Example #30
Source File: application.py    From Python-GUI-Programming-with-Tkinter with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.title("ABQ Data Entry Application")
        self.resizable(width=False, height=False)

        # new code for ch6
        datestring = datetime.today().strftime("%Y-%m-%d")
        default_filename = "abq_data_record_{}.csv".format(datestring)
        self.filename = tk.StringVar(value=default_filename)
        self.settings_model = m.SettingsModel()
        self.load_settings()

        self.callbacks = {
            'file->select': self.on_file_select,
            'file->quit': self.quit
        }

        menu = v.MainMenu(self, self.settings, self.callbacks)
        self.config(menu=menu)
        self.recordform = v.DataRecordForm(
            self, m.CSVModel.fields, self.settings)
        # end new

        self.recordform.grid(row=1, padx=10)

        self.savebutton = ttk.Button(self, text="Save", command=self.on_save)
        self.savebutton.grid(sticky="e", row=2, padx=10)

        # status bar
        self.status = tk.StringVar()
        self.statusbar = ttk.Label(self, textvariable=self.status)
        self.statusbar.grid(sticky="we", row=3, padx=10)

        self.records_saved = 0