Python tkinter.X Examples

The following are 30 code examples of tkinter.X(). 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 , or try the search function .
Example #1
Source File: friendslist.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def load_friends(self):
        my_friends = self.requester.get_friends(self.username)
        for user in my_friends["friends"]:
            if user['username'] != self.username:
                friend_frame = ttk.Frame(self.canvas_frame)

                friend_avatar_path = os.path.join(friend_avatars_dir, f"{user['username']}.png")

                if user["avatar"]:
                    with open(friend_avatar_path, 'wb') as friend_avatar:
                        img = base64.urlsafe_b64decode(user['avatar'])
                        friend_avatar.write(img)
                else:
                    friend_avatar_path = default_avatar_path

                profile_photo = tk.PhotoImage(file=friend_avatar_path)
                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"], avatar=friend_avatar_path)
                block_this_friend = partial(self.block_friend, username=user["username"])

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

                profile_photo_label.pack(side=tk.LEFT)
                friend_name.pack(side=tk.LEFT)
                message_button.pack(side=tk.RIGHT)
                block_button.pack(side=tk.RIGHT, padx=(0, 30))

                friend_frame.pack(fill=tk.X, expand=1) 
Example #2
Source File: DockManager.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def undock(self, dock, x=None, y=None):
        """Warning: On Mac OS X 10.5 undocking works imperfectly.
        Left and right docking work fine though.
        """
        dock.pack_forget()
        dock.config(relief=tk.FLAT, borderwidth=0)
        dock.tk.call("wm", "manage", dock)
        on_close = dock.register(dock.on_close)
        dock.tk.call("wm", "protocol", dock, "WM_DELETE_WINDOW", on_close)
        title = dock.title if hasattr(dock, "title") else "Dock"
        dock.tk.call("wm", "title", dock, title)
        minsize = dock.minsize if hasattr(dock, "minsize") else (60, 30)
        dock.tk.call("wm", "minsize", dock, *minsize)
        dock.tk.call("wm", "resizable", dock, False, False)
        if TkUtil.windows():
            dock.tk.call("wm", "attributes", dock, "-toolwindow", True)
        if x is not None and y is not None:
            self.xy_for_dock[dock] = (x, y)
        x, y = self.xy_for_dock.get(dock, (None, None))
        if x is not None and y is not None:
            dock.tk.call("wm", "geometry", dock, "{:+}{:+}".format(x, y))
        self.__remove_area(dock) 
Example #3
Source File: _backend_tk.py    From Mastering-Elasticsearch-7.0 with MIT License 6 votes vote down vote up
def _init_toolbar(self):
        xmin, xmax = self.canvas.figure.bbox.intervalx
        height, width = 50, xmax-xmin
        tk.Frame.__init__(self, master=self.window,
                          width=int(width), height=int(height),
                          borderwidth=2)

        self.update()  # Make axes menu

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                # Add a spacer; return value is unused.
                self._Spacer()
            else:
                button = self._Button(text=text, file=image_file,
                                      command=getattr(self, callback))
                if tooltip_text is not None:
                    ToolTip.createToolTip(button, tooltip_text)

        self.message = tk.StringVar(master=self)
        self._message_label = tk.Label(master=self, textvariable=self.message)
        self._message_label.pack(side=tk.RIGHT)
        self.pack(side=tk.BOTTOM, fill=tk.X) 
Example #4
Source File: CInScan02.py    From mcculw with MIT License 6 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        if self.chan_num != -1:
            self.results_group = tk.LabelFrame(
                self, text="Results", padx=3, pady=3)
            self.results_group.pack(
                fill=tk.X, anchor=tk.NW, padx=3, pady=3)

            self.data_frame = tk.Frame(self.results_group)
            self.data_frame.grid()

            button_frame = tk.Frame(self)
            button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

            self.start_button = tk.Button(button_frame)
            self.start_button["text"] = "Start"
            self.start_button["command"] = self.start
            self.start_button.grid(row=0, column=0, padx=3, pady=3)

            quit_button = tk.Button(button_frame)
            quit_button["text"] = "Quit"
            quit_button["command"] = self.master.destroy
            quit_button.grid(row=0, column=1, padx=3, pady=3)
        else:
            self.create_unsupported_widgets(self.board_num) 
Example #5
Source File: statusbar.py    From vy with MIT License 6 votes vote down vote up
def __init__(self, master):
        Frame.__init__(self, master)
        self.config(border=1)

        self.msg = Label(self, bd=1, relief=SUNKEN, anchor=W)
        self.msg.pack(side='left', expand=True, fill=X)

        self.column = Label(self, bd=1, relief=SUNKEN, anchor=W)
        self.column.config(text='Col: 0')
        self.column.pack(side='right', fill=X)

        self.line = Label(self, bd=1, relief=SUNKEN, anchor=W)
        self.line.config(text='Line: 1')
        self.line.pack(side='right', fill=X)


        self.mode = Label(self, bd=1, relief=SUNKEN, anchor=W)
        self.mode.config(text='Mode: 1')
        self.mode.pack(side='right', fill=X) 
Example #6
Source File: _backend_tk.py    From GraphicDesignPatternByPython with MIT License 6 votes vote down vote up
def _init_toolbar(self):
        xmin, xmax = self.canvas.figure.bbox.intervalx
        height, width = 50, xmax-xmin
        Tk.Frame.__init__(self, master=self.window,
                          width=int(width), height=int(height),
                          borderwidth=2)

        self.update()  # Make axes menu

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                # Add a spacer; return value is unused.
                self._Spacer()
            else:
                button = self._Button(text=text, file=image_file,
                                      command=getattr(self, callback))
                if tooltip_text is not None:
                    ToolTip.createToolTip(button, tooltip_text)

        self.message = Tk.StringVar(master=self)
        self._message_label = Tk.Label(master=self, textvariable=self.message)
        self._message_label.pack(side=Tk.RIGHT)
        self.pack(side=Tk.BOTTOM, fill=Tk.X) 
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):
        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="Jaden Corebyn", anchor=tk.W)

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

        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: control_helper.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def add_info(self, frame):
        """ Plugin information """
        gui_style = ttk.Style()
        gui_style.configure('White.TFrame', background='#FFFFFF')
        gui_style.configure('Header.TLabel',
                            background='#FFFFFF',
                            font=get_config().default_font + ("bold", ))
        gui_style.configure('Body.TLabel',
                            background='#FFFFFF')

        info_frame = ttk.Frame(frame, style='White.TFrame', relief=tk.SOLID)
        info_frame.pack(fill=tk.X, side=tk.TOP, expand=True, padx=10, pady=10)
        label_frame = ttk.Frame(info_frame, style='White.TFrame')
        label_frame.pack(padx=5, pady=5, fill=tk.X, expand=True)
        for idx, line in enumerate(self.header_text.splitlines()):
            if not line:
                continue
            style = "Header.TLabel" if idx == 0 else "Body.TLabel"
            info = ttk.Label(label_frame, text=line, style=style, anchor=tk.W)
            info.bind("<Configure>", self._adjust_wraplength)
            info.pack(fill=tk.X, padx=0, pady=0, expand=True, side=tk.TOP) 
Example #9
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 #10
Source File: ch4.py    From Tkinter-GUI-Programming-by-Example with MIT License 6 votes vote down vote up
def __init__(self):
        super().__init__()
        self.title("Blackjack")
        self.geometry("800x640")
        self.resizable(False, False)

        self.bottom_frame = tk.Frame(self, width=800, height=140, bg="red")
        self.bottom_frame.pack_propagate(0)

        self.hit_button = tk.Button(self.bottom_frame, text="Hit", width=25, command=self.hit)
        self.stick_button = tk.Button(self.bottom_frame, text="Stick", width=25, command=self.stick)

        self.next_round_button = tk.Button(self.bottom_frame, text="Next Round", width=25, command=self.next_round)
        self.quit_button = tk.Button(self.bottom_frame, text="Quit", width=25, command=self.destroy)

        self.new_game_button = tk.Button(self.bottom_frame, text="New Game", width=25, command=self.new_game)

        self.bottom_frame.pack(side=tk.BOTTOM, fill=tk.X)

        self.game_screen = GameScreen(self, bg="white", width=800, height=500)
        self.game_screen.pack(side=tk.LEFT, anchor=tk.N)
        self.game_screen.setup_opening_animation() 
Example #11
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def get_group_frame(self, group):
        """ Return a new group frame """
        group = group.lower()
        if self.group_frames.get(group, None) is None:
            logger.debug("Creating new group frame for: %s", group)
            is_master = group == "_master"
            opts_frame = self.optsframe.subframe
            if is_master:
                group_frame = ttk.Frame(opts_frame, name=group.lower())
            else:
                group_frame = ttk.LabelFrame(opts_frame,
                                             text="" if is_master else group.title(),
                                             name=group.lower())

            group_frame.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5, anchor=tk.NW)

            self.group_frames[group] = dict(frame=group_frame,
                                            chkbtns=self.checkbuttons_frame(group_frame))
        group_frame = self.group_frames[group]
        return group_frame 
Example #12
Source File: toolkit.py    From PickTrue with MIT License 6 votes vote down vote up
def __init__(self, master=None, store_name=None, **kwargs):
        super(FileBrowse, self).__init__(master=master, **kwargs)
        self.label_text = tk.StringVar()
        btn = tk.Button(self, text="下载到", command=self.choose_file)
        btn.pack(
            side=tk.LEFT,
        )

        tk.Label(self, textvariable=self.label_text).pack(
            side=tk.LEFT,
            fill=tk.X,
        )
        self.pack(fill=tk.X)

        self._store_name = store_name
        if store_name is not None:
            self._config = config_store
            save_path = self._config.op_read_path(store_name) or get_working_dir()
        else:
            self._config = None
            save_path = get_working_dir()

        self.label_text.set(
            save_path
        ) 
Example #13
Source File: _backend_tk.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _init_toolbar(self):
        xmin, xmax = self.canvas.figure.bbox.intervalx
        height, width = 50, xmax-xmin
        Tk.Frame.__init__(self, master=self.window,
                          width=int(width), height=int(height),
                          borderwidth=2)

        self.update()  # Make axes menu

        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                # Add a spacer; return value is unused.
                self._Spacer()
            else:
                button = self._Button(text=text, file=image_file,
                                      command=getattr(self, callback))
                if tooltip_text is not None:
                    ToolTip.createToolTip(button, tooltip_text)

        self.message = Tk.StringVar(master=self)
        self._message_label = Tk.Label(master=self, textvariable=self.message)
        self._message_label.pack(side=Tk.RIGHT)
        self.pack(side=Tk.BOTTOM, fill=Tk.X) 
Example #14
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def _get_subgroup_frame(self, parent, subgroup):
        if subgroup is None:
            return subgroup
        if subgroup not in self._sub_group_frames:
            sub_frame = ttk.Frame(parent, name="subgroup_{}".format(subgroup))
            self._sub_group_frames[subgroup] = AutoFillContainer(sub_frame,
                                                                 self.option_columns,
                                                                 self.option_columns)
            sub_frame.pack(anchor=tk.W, expand=True, fill=tk.X)
            logger.debug("Added Subgroup Frame: %s", subgroup)
        return self._sub_group_frames[subgroup] 
Example #15
Source File: base.py    From guizero with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _pack_widget(self, widget):
        pack_params={}

        if widget.width == "fill" and widget.height == "fill":
            pack_params["fill"] = BOTH
            pack_params["expand"] = YES
        elif widget.width == "fill":
            pack_params["fill"] = X
        elif widget.height == "fill":
            pack_params["fill"] = Y

        if widget.align is not None:
            pack_params["side"] = widget.align

        # this is to cater for scenario's where the frame will not expand to fill the container
        # if aligned - tk weirdness.
        if pack_params.get("side") is None and pack_params.get("fill") == Y:
            pack_params["expand"] = YES

        if pack_params.get("side") in ["top", "bottom"] and pack_params.get("fill") == Y:
            pack_params["expand"] = YES

        if pack_params.get("side") in ["left", "right"] and pack_params.get("fill") == X:
            pack_params["expand"] = YES

        widget.tk.pack(**pack_params) 
Example #16
Source File: popup_configure.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def add_frame_separator(self):
        """ Add a separator between top and bottom frames """
        logger.debug("Add frame seperator")
        sep = ttk.Frame(self.page_frame, height=2, relief=tk.RIDGE)
        sep.pack(fill=tk.X, pady=(5, 0), side=tk.BOTTOM)
        logger.debug("Added frame seperator") 
Example #17
Source File: menu.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def _section_separator(self):
        frame = ttk.Frame(self)
        frame.pack(side=tk.BOTTOM, fill=tk.X)
        separator = ttk.Separator(frame, orient="horizontal")
        separator.pack(fill=tk.X, side=tk.LEFT, expand=True) 
Example #18
Source File: menu.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        super().__init__(parent)
        self._config = get_config()
        self.pack(side=tk.TOP, anchor=tk.W, fill=tk.X, expand=False)
        self._btn_frame = ttk.Frame(self)
        self._btn_frame.pack(side=tk.TOP, pady=2, anchor=tk.W, fill=tk.X, expand=False)

        self._project_btns()
        self._group_separator()
        self._task_btns()
        self._group_separator()
        self._settings_btns()
        self._section_separator() 
Example #19
Source File: display_command.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def add_option_smoothing(self):
        """ Add refresh button to refresh graph immediately """
        logger.debug("Adding Smoothing Slider")
        tk_var = get_config().tk_vars["smoothgraph"]
        min_max = (0, 0.99)
        hlp = "Set the smoothing amount. 0 is no smoothing, 0.99 is maximum smoothing."

        ctl_frame = ttk.Frame(self.optsframe)
        ctl_frame.pack(padx=2, side=tk.RIGHT)

        lbl = ttk.Label(ctl_frame, text="Smoothing Amount:", anchor=tk.W)
        lbl.pack(pady=5, side=tk.LEFT, anchor=tk.N, expand=True)

        tbox = ttk.Entry(ctl_frame, width=6, textvariable=tk_var, justify=tk.RIGHT)
        tbox.pack(padx=(0, 5), side=tk.RIGHT)

        ctl = ttk.Scale(
            ctl_frame,
            variable=tk_var,
            command=lambda val, var=tk_var, dt=float, rn=2, mm=(0, 0.99):
            set_slider_rounding(val, var, dt, rn, mm))
        ctl["from_"] = min_max[0]
        ctl["to"] = min_max[1]
        ctl.pack(padx=5, pady=5, fill=tk.X, expand=True)
        for item in (tbox, ctl):
            Tooltip(item,
                    text=hlp,
                    wraplength=200)
        logger.debug("Added Smoothing Slider") 
Example #20
Source File: ULDO01.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        if self.port != None:
            main_frame = tk.Frame(self)
            main_frame.pack(fill=tk.X, anchor=tk.NW)

            positive_int_vcmd = self.register(self.validate_positive_int_entry)

            curr_row = 0
            value_label = tk.Label(main_frame)
            value_label["text"] = "Value:"
            value_label.grid(row=curr_row, column=0, sticky=tk.W)

            self.data_value_variable = StringVar()
            self.data_value_entry = tk.Spinbox(
                main_frame, from_=0, to=255, textvariable=self.data_value_variable,
                validate="key", validatecommand=(positive_int_vcmd, "%P"))
            self.data_value_entry.grid(row=curr_row, column=1, sticky=tk.W)
            self.data_value_variable.trace("w", self.data_value_changed)

            button_frame = tk.Frame(self)
            button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

            quit_button = tk.Button(button_frame)
            quit_button["text"] = "Quit"
            quit_button["command"] = self.exit
            quit_button.grid(row=0, column=1, padx=3, pady=3)
        else:
            self.create_unsupported_widgets(self.board_num) 
Example #21
Source File: clai_emulator.py    From clai with MIT License 5 votes vote down vote up
def add_toolbar(self, root):
        toolbar = tk.Frame(root, bd=1, relief=tk.RAISED)
        self.add_play_button(toolbar)
        self.add_refresh_button(toolbar)
        self.add_log_button(toolbar)
        self.add_skills_selector(root, toolbar)
        self.add_loading_progress(toolbar)

        toolbar.pack(side=tk.TOP, fill=tk.X) 
Example #22
Source File: ULGT01.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        main_frame = tk.Frame(self)
        main_frame.pack(fill=tk.X, anchor=tk.NW)

        positive_int_vcmd = self.register(self.validate_positive_int_entry)

        err_code_label = tk.Label(main_frame)
        err_code_label["text"] = "Error Code:"
        err_code_label.grid(row=0, column=0, sticky=tk.W)

        self.err_code_variable = StringVar(0)
        self.err_code_entry = tk.Spinbox(
            main_frame, from_=0, to=2000,
            textvariable=self.err_code_variable,
            validate="key", validatecommand=(positive_int_vcmd, "%P"))
        self.err_code_entry.grid(row=0, column=1, sticky=tk.W)
        self.err_code_variable.trace("w", self.err_code_changed)

        err_msg_left_label = tk.Label(main_frame)
        err_msg_left_label["text"] = "Message:"
        err_msg_left_label.grid(row=1, column=0, sticky=tk.NW)

        self.err_msg_label = tk.Label(
            main_frame, justify=tk.LEFT, wraplength=300)
        self.err_msg_label["text"] = "No error has occurred."
        self.err_msg_label.grid(row=1, column=1, sticky=tk.W)

        button_frame = tk.Frame(self)
        button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

        quit_button = tk.Button(button_frame)
        quit_button["text"] = "Quit"
        quit_button["command"] = self.master.destroy
        quit_button.grid(row=0, column=0, padx=3, pady=3)


# Start the example if this module is being run 
Example #23
Source File: ULGT03.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        main_frame = tk.Frame(self)
        main_frame.pack(fill=tk.X, anchor=tk.NW)

        positive_int_vcmd = self.register(self.validate_positive_int_entry)

        board_num_label = tk.Label(main_frame)
        board_num_label["text"] = "Board Number:"
        board_num_label.grid(row=0, column=0, sticky=tk.W)

        self.board_num_variable = StringVar()
        board_num_entry = tk.Spinbox(
            main_frame, from_=0, to=self.max_board_num,
            textvariable=self.board_num_variable,
            validate="key", validatecommand=(positive_int_vcmd, "%P"))
        board_num_entry.grid(row=0, column=1, sticky=tk.W)
        self.board_num_variable.trace("w", self.board_num_changed)

        info_groupbox = tk.LabelFrame(self, text="Board Information")
        info_groupbox.pack(fill=tk.X, anchor=tk.NW, padx=3, pady=3)

        self.info_label = tk.Label(
            info_groupbox, justify=tk.LEFT, wraplength=400)
        self.info_label.grid()

        button_frame = tk.Frame(self)
        button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

        quit_button = tk.Button(button_frame)
        quit_button["text"] = "Quit"
        quit_button["command"] = self.master.destroy
        quit_button.grid(row=0, column=0, padx=3, pady=3)


# Start the example if this module is being run 
Example #24
Source File: uiexample.py    From mcculw with MIT License 5 votes vote down vote up
def create_unsupported_widgets(self, board_num):
        incompatible_label = tk.Label(self, fg="red")
        incompatible_label["text"] = (
            "Board " + str(board_num)
            + " was not found or is not compatible with this example.")
        incompatible_label.pack(fill=tk.X, side=tk.LEFT, anchor=tk.NW)

        button_frame = tk.Frame(self)
        button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

        quit_button = tk.Button(button_frame)
        quit_button["text"] = "Quit"
        quit_button["command"] = self.master.destroy
        quit_button.grid(row=0, column=0, padx=3, pady=3) 
Example #25
Source File: CInScan03.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        if self.chan_num != -1:
            info_text = tk.Label(self)
            info_text["text"] = (
                "Encoder scan on device " + str(self.board_num)
                + " counter channel " + str(self.chan_num))
            info_text.pack(fill=tk.X, anchor=tk.NW, padx=3, pady=3)

            results_group = tk.LabelFrame(self, text="Results")
            results_group.pack(fill=tk.X, anchor=tk.NW, padx=3, pady=3)

            self.data_label = tk.Label(results_group, justify=tk.LEFT)
            self.data_label.grid(padx=3, pady=3)

            button_frame = tk.Frame(self)
            button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

            self.start_button = tk.Button(button_frame)
            self.start_button["text"] = "Start"
            self.start_button["command"] = self.start
            self.start_button.grid(row=0, column=0, padx=3, pady=3)

            quit_button = tk.Button(button_frame)
            quit_button["text"] = "Quit"
            quit_button["command"] = self.master.destroy
            quit_button.grid(row=0, column=1, padx=3, pady=3)
        else:
            self.create_unsupported_widgets(self.board_num)


# Start the example if this module is being run 
Example #26
Source File: ULDO02.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        if self.port != None:
            main_frame = tk.Frame(self)
            main_frame.pack(fill=tk.X, anchor=tk.NW)

            curr_row = 0
            bit_values_frame = tk.Frame(main_frame)
            bit_values_frame.grid(row=curr_row, column=0, padx=3, pady=3)

            label = tk.Label(bit_values_frame, text="Bit Number:")
            label.grid(row=0, column=0, sticky=tk.W)

            label = tk.Label(bit_values_frame, text="State:")
            label.grid(row=1, column=0, sticky=tk.W)

            # Create Checkbutton controls for each bit
            self.bit_checkbutton_vars = []
            max_bit = min(self.port.num_bits, 8)
            for bit_num in range(0, max_bit):
                bit_label = tk.Label(bit_values_frame, text=str(bit_num))
                bit_label.grid(row=0, column=bit_num + 1)

                var = IntVar(value=-1)
                bit_checkbutton = tk.Checkbutton(
                    bit_values_frame, tristatevalue=-1, variable=var,
                    borderwidth=0,
                    command=lambda n=bit_num:
                    self.bit_checkbutton_changed(n))
                bit_checkbutton.grid(row=1, column=bit_num + 1, padx=(5, 0))
                self.bit_checkbutton_vars.append(var)

            button_frame = tk.Frame(self)
            button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

            quit_button = tk.Button(button_frame)
            quit_button["text"] = "Quit"
            quit_button["command"] = self.exit
            quit_button.grid(row=0, column=0, padx=3, pady=3)
        else:
            self.create_unsupported_widgets(self.board_num) 
Example #27
Source File: ULDI06.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        if self.port != None:
            main_frame = tk.Frame(self)
            main_frame.pack(fill=tk.X, anchor=tk.NW)

            curr_row = 0
            raw_value_left_label = tk.Label(main_frame)
            raw_value_left_label["text"] = (
                self.port.type.name + " bit " + str(self.port.first_bit)
                + " value read:")
            raw_value_left_label.grid(row=curr_row, column=0, sticky=tk.W)

            self.value_label = tk.Label(main_frame)
            self.value_label.grid(row=curr_row, column=1, sticky=tk.W)

            button_frame = tk.Frame(self)
            button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

            self.start_button = tk.Button(button_frame)
            self.start_button["text"] = "Start"
            self.start_button["command"] = self.start
            self.start_button.grid(row=0, column=0, padx=3, pady=3)

            quit_button = tk.Button(button_frame)
            quit_button["text"] = "Quit"
            quit_button["command"] = self.master.destroy
            quit_button.grid(row=0, column=1, padx=3, pady=3)
        else:
            self.create_unsupported_widgets(self.board_num) 
Example #28
Source File: googletranslateui.py    From google-translate-for-goldendict with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, window):
        self.window = window
        self.window.title('Google Translate')

        frm = tk.Frame(self.window)
        frm.pack(anchor=tk.NW, fill=tk.BOTH, expand=1)

        frm_input = tk.Frame(frm)
        frm_output = tk.Frame(frm)
        frm_input.pack(anchor=tk.NW, fill=tk.X)
        frm_output.pack(anchor=tk.NW, fill=tk.BOTH, expand=1)

        self.input_text = tk.StringVar()
        self.input_entry = ttk.Entry(frm_input, textvariable=self.input_text)
        self.input_entry.pack(side=tk.LEFT, fill=tk.X, expand=1)

        self.run_queue = Queue()
        self.trans_button = ttk.Button(frm_input, text='trans', width=6, command=self.run)
        self.trans_button.pack(anchor=tk.NE, side=tk.LEFT)

        self.st = scrolledtext.ScrolledText(frm_output, state=tk.NORMAL)
        self.st.insert(tk.END, 'Google Translate\n')
        self.st.pack(anchor=tk.NW, fill=tk.BOTH, expand=1)

        self.input_entry.bind('<Return>', self.run)
        self.input_entry.bind('<Escape>', lambda event=None: self.input_text.set('')) 
Example #29
Source File: _backend_tk.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, window, *args, **kwargs):
        StatusbarBase.__init__(self, *args, **kwargs)
        xmin, xmax = self.toolmanager.canvas.figure.bbox.intervalx
        height, width = 50, xmax - xmin
        Tk.Frame.__init__(self, master=window,
                          width=int(width), height=int(height),
                          borderwidth=2)
        self._message = Tk.StringVar(master=self)
        self._message_label = Tk.Label(master=self, textvariable=self._message)
        self._message_label.pack(side=Tk.RIGHT)
        self.pack(side=Tk.TOP, fill=Tk.X) 
Example #30
Source File: toolkit.py    From PickTrue with MIT License 5 votes vote down vote up
def __init__(self, master):
        tk.Frame.__init__(self, master)
        self.variable=tk.StringVar()
        self.label=tk.Label(
            self, bd=1, relief=tk.SUNKEN, anchor=tk.W,
            textvariable=self.variable,
            font=('arial', 16, 'normal')
        )
        self.variable.set('')
        self.label.pack(fill=tk.X)
        self.pack(fill=tk.BOTH)