Python tkinter.N Examples

The following are 30 code examples of tkinter.N(). 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: chapter2_04.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 7 votes vote down vote up
def __init__(self):
        super().__init__()
        label_a = tk.Label(self, text="Label A", bg="yellow")
        label_b = tk.Label(self, text="Label B", bg="orange")
        label_c = tk.Label(self, text="Label C", bg="red")
        label_d = tk.Label(self, text="Label D", bg="green")
        label_e = tk.Label(self, text="Label E", bg="blue")

        label_a.place(relwidth=0.25, relheight=0.25)
        label_b.place(x=100, anchor=tk.N,
                      width=100, height=50)
        label_c.place(relx=0.5, rely=0.5, anchor=tk.CENTER,
                      relwidth=0.5, relheight=0.5)
        label_d.place(in_=label_c, anchor=tk.N + tk.W,
                      x=2, y=2, relx=0.5, rely=0.5,
                      relwidth=0.5, relheight=0.5)
        label_e.place(x=200, y=200, anchor=tk.S + tk.E,
                      relwidth=0.25, relheight=0.25) 
Example #2
Source File: gui.py    From halucinator with GNU General Public License v3.0 6 votes vote down vote up
def set_layout(self):
        '''
            Sets the layout for the gui
        '''
        s = tkinter.ttk.Style()
        s.theme_use('clam')

        # Layout column 0
        self.table_funcs.grid(column=0, row=0, sticky=tk.W+tk.E)
        self.tree.grid(column=0, row=1, sticky=tk.W+tk.E+tk.N+tk.S)

        # Layout column 1
        self.record_label.grid(column=1, row=0, sticky=tk.W+tk.E)
        self.record_tree.grid(column=1, row=1, sticky=tk.W+tk.E+tk.N+tk.S)

        self.root.grid_columnconfigure(0, minsize=300)
        self.root.grid_columnconfigure(1, weight=1, minsize=500)
        self.root.grid_rowconfigure(1, weight=1) 
Example #3
Source File: cameraConfig.py    From crappy with GNU General Public License v2.0 6 votes vote down vote up
def create_window(self):
    self.root.grid_rowconfigure(1,weight=1)
    self.root.grid_columnconfigure(0,weight=1)
    self.img_label = tk.Label(self.root)
    self.img_label.configure(image=self.c_img)
    self.hist_label = tk.Label(self.root)
    self.hist_label.grid(row=0,column=0)
    #self.img_label.pack(fill=tk.BOTH)
    self.img_label.grid(row=1,column=0,
        rowspan=len(self.camera.settings_dict)+2, sticky=tk.N+tk.E+tk.S+tk.W)
    self.create_inputs()
    self.create_infos()
    self.img_label.bind('<Motion>', self.update_reticle)
    self.img_label.bind('<4>', self.zoom_in)
    self.img_label.bind('<5>', self.zoom_out)
    self.root.bind('<MouseWheel>', self.zoom)
    self.img_label.bind('<1>', self.start_move)
    self.img_label.bind('<B1-Motion>', self.move) 
Example #4
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 #5
Source File: downloader.py    From PickTrue with MIT License 6 votes vote down vote up
def build_buttons(self):
        btn_args = dict(
            height=1,
        )
        btn_group = tk.Frame(self)

        buttons = [
            tk.Button(
                btn_group,
                text=text,
                command=command,
                **btn_args
            )
            for text, command in (
                ("开始下载", self.start_download),
                ("停止下载", self.stop_download),
                ("打开下载文件夹", self.open_download_folder),
            )
        ]

        for index, btn in enumerate(buttons):
            btn.grid(column=index, row=0, sticky=tk.N)

        btn_group.pack(fill=tk.BOTH, expand=1)
        return btn_group 
Example #6
Source File: view.py    From ms_deisotope with Apache License 2.0 6 votes vote down vote up
def configure_canvas(self):
        self.figure = Figure(dpi=100)
        self.canvas = FigureCanvasTkAgg(self.figure, master=self)
        self.axis = self.figure.add_subplot(111)
        self.canvas.draw()
        canvas_widget = self.canvas.get_tk_widget()
        canvas_widget.grid(row=0, column=0, sticky=tk.N + tk.W + tk.E + tk.S)
        self.canvas_cursor = Cursor(self.axis, tk.StringVar(master=self.root))
        self.canvas.mpl_connect('motion_notify_event', self.canvas_cursor.mouse_move)
        self.span = SpanSelector(
            self.axis, self.zoom, 'horizontal', useblit=True,
            rectprops=dict(alpha=0.5, facecolor='red'))
        self.mz_span = None
        self.scan = None
        self.annotations = []
        self.canvas.draw() 
Example #7
Source File: view.py    From ms_deisotope with Apache License 2.0 6 votes vote down vote up
def configure_treeview(self):
        self.treeview = ttk.Treeview(self)
        self.treeview['columns'] = ["id", "time", 'ms_level', 'precursor_mz', 'precursor_charge', 'activation']
        self.treeview.grid(row=2, column=0, sticky=tk.S + tk.W + tk.E + tk.N)

        self.treeview_scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.treeview.yview)
        self.treeview_scrollbar.grid(row=2, column=0, sticky=tk.S + tk.E + tk.N)
        self.treeview.configure(yscrollcommand=self.treeview_scrollbar.set)

        self.treeview.heading('id', text="Scan ID")
        self.treeview.heading('#0', text='Index')
        self.treeview.heading("time", text='Time (min)')
        self.treeview.heading("ms_level", text='MS Level')
        self.treeview.heading("precursor_mz", text='Precursor M/Z')
        self.treeview.heading("precursor_charge", text='Precursor Z')
        self.treeview.heading("activation", text='Activation')
        self.treeview.column("#0", width=75)
        self.treeview.column("ms_level", width=75)
        self.treeview.column("time", width=75)
        self.treeview.column("precursor_mz", width=100)
        self.treeview.column("precursor_charge", width=100)
        self.treeview.bind("<<TreeviewSelect>>", self.on_row_click) 
Example #8
Source File: UICommon.py    From RaspberryPiBarcodeScanner with MIT License 6 votes vote down vote up
def table(self, master, title, content, target=None, backgroundcolour="White", foregroundcolour="black", bordercolour="grey", borderwidth=1, fontstyle="DejaVuSans 18 normal"):
        # creates a table from a 2 dimensional array.  
        # master: = this represents the parent window
        # content: a 2 dimensional array containing the table contents
        # First column in the array must be the row id which is returned on a click event.  This will not be displayed in the table
        index = 0
        for i in range(len(content)): #Rows
            for j in range(len(content[i])):
                if j==0: 
                    index = content[i][j]
                else:
                    b = tk.Label(master, text=str(content[i][j]), background=backgroundcolour, foreground=foregroundcolour,padx=5, pady=10, highlightthickness=borderwidth, highlightbackground=bordercolour, font=fontstyle)
                    if (target is not None):
                        b.bind('<ButtonPress-1>', self.__row_pressed)  
                        b.bind('<ButtonRelease-1>', lambda event, arg1=index, arg2=target: self.__row_released(event, arg1, arg2))                 
                    b.grid(row=i, column=j-1, sticky=tk.N+tk.S+tk.E+tk.W)
        return 
Example #9
Source File: solution_tab_frame_gui.py    From pyDEA with MIT License 6 votes vote down vote up
def _create_file_format_btn(self, btn_text, var_value, parent, column):
        ''' Creates and grids Radiobutton used for choosing solution file
            format.

            Args:
                btn_text (str): text displayed next to the Radiobutton.
                var_value (int): value of the IntVar associated with this
                    Radiobutton.
                parent (Tk object): parent of this Radiobutton.
                column (int): column index where this Radiobutton
                    should be gridded.
        '''
        sol_format_btn = Radiobutton(parent, text=btn_text,
                                     variable=self.solution_format_var,
                                     value=var_value)
        sol_format_btn.grid(row=2, column=column, sticky=W+N, padx=2) 
Example #10
Source File: text_frame_gui.py    From pyDEA with MIT License 6 votes vote down vote up
def create_widgets(self):
        ''' Creates all widgets.
        '''
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)

        xscrollbar = Scrollbar(self, orient=HORIZONTAL)
        xscrollbar.grid(row=1, column=0, sticky=E+W)

        yscrollbar = Scrollbar(self)
        yscrollbar.grid(row=0, column=1, sticky=N+S)

        self.text = Text(self, wrap=NONE,
                         xscrollcommand=xscrollbar.set,
                         yscrollcommand=yscrollbar.set)

        self.text.bind("<Control-Key-a>", self.select_all)
        self.text.bind("<Control-Key-A>", self.select_all)

        self.text.grid(row=0, column=0, sticky=N+S+E+W)

        xscrollbar.config(command=self.text.xview)
        yscrollbar.config(command=self.text.yview) 
Example #11
Source File: load_xls_gui.py    From pyDEA with MIT License 6 votes vote down vote up
def create_widgets(self, names):
        ''' Creates appropriate widgets.

            Args:
                names (list of str): list of available sheet names.
        '''
        sheet_name_lbl = Label(self,
                               text='Choose sheet name where data is stored:')
        sheet_name_lbl.grid(sticky=N+W, padx=5, pady=5)
        sheet_names_box = Combobox(self, state="readonly", width=20,
                                   textvariable=self.sheet_name_str,
                                   values=names)
        sheet_names_box.current(0)
        sheet_names_box.grid(row=1, column=0, columnspan=2,
                             sticky=N+W, padx=5, pady=5)
        ok_btn = Button(self, text='OK', command=self.ok)
        ok_btn.grid(row=2, column=0, sticky=N+E, padx=5, pady=5)
        ok_btn.bind('<Return>', self.ok)
        ok_btn.focus()
        cancel_btn = Button(self, text='Cancel', command=self.cancel)
        cancel_btn.grid(row=2, column=1, sticky=N+E, padx=5, pady=5)
        cancel_btn.bind('<Return>', self.cancel) 
Example #12
Source File: recipe-578871.py    From code with MIT License 6 votes vote down vote up
def __init__( self, parent, scale, historySize, trackColors, *args, **opts ):
      # Initialize
      super().__init__( parent, *args, **opts )
      self._trackHist   = OrderedDict() # Map: TrackName -> list of canvas objID 
      self._trackColor  = trackColors   # Map: Track Name -> color
      
      self._chartHeight = scale + 1
      self._chartLength = historySize * 2  # Stretch for readability

      self._canvas = tk.Canvas( self, height=self._chartHeight + 17,
                                width=self._chartLength, background='black' )
      self._canvas.grid( sticky=tk.N+tk.S+tk.E+tk.W )
      
      # Draw horizontal to divide plot from tick labels
      x,  y  = 0, self._chartHeight + 2
      x2, y2 = self._chartLength, y
      self._baseLine = self._canvas.create_line( x, y, x2, y2, fill='white' )
      
      # Init track def and histories lists
      self._trackColor.update( { 'tick':'white', 'tickline':'white',
                                 'ticklabel':'white' } )
      for trackName in self._trackColor.keys():
         self._trackHist[ trackName ] = [ None for x in range(historySize) ] 
Example #13
Source File: main.py    From tkinter-logging-text-widget with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def __init__(self, frame):
        self.frame = frame
        # Create a ScrolledText wdiget
        self.scrolled_text = ScrolledText(frame, state='disabled', height=12)
        self.scrolled_text.grid(row=0, column=0, sticky=(N, S, W, E))
        self.scrolled_text.configure(font='TkFixedFont')
        self.scrolled_text.tag_config('INFO', foreground='black')
        self.scrolled_text.tag_config('DEBUG', foreground='gray')
        self.scrolled_text.tag_config('WARNING', foreground='orange')
        self.scrolled_text.tag_config('ERROR', foreground='red')
        self.scrolled_text.tag_config('CRITICAL', foreground='red', underline=1)
        # Create a logging handler using a queue
        self.log_queue = queue.Queue()
        self.queue_handler = QueueHandler(self.log_queue)
        formatter = logging.Formatter('%(asctime)s: %(message)s')
        self.queue_handler.setFormatter(formatter)
        logger.addHandler(self.queue_handler)
        # Start polling messages from the queue
        self.frame.after(100, self.poll_log_queue) 
Example #14
Source File: downloader.py    From PickTrue with MIT License 6 votes vote down vote up
def build_buttons(self):
        btn_args = dict(
            height=1,
        )
        btn_group = tk.Frame(self)

        buttons = [
            tk.Button(
                btn_group,
                text=text,
                command=command,
                **btn_args
            )
            for text, command in (
                ("开始下载", self.start_download),
                ("停止下载", self.stop_download),
                ("打开下载文件夹", self.open_download_folder),
            )
        ]

        for index, btn in enumerate(buttons):
            btn.grid(column=index, row=0, sticky=tk.N)

        btn_group.pack(fill=tk.BOTH, expand=1)
        return btn_group 
Example #15
Source File: symbol_browser.py    From halucinator with GNU General Public License v3.0 6 votes vote down vote up
def set_layout(self):
        '''
            Sets the layout for the gui
        '''
        s = ttk.Style()
        s.theme_use('clam')

        # Layout column 0
        self.table_funcs.grid(column=0, row=0, sticky=tk.W+tk.E)
        self.tree.grid(column=0, row=1, sticky=tk.W+tk.E+tk.N+tk.S)

        # Layout column 1
        self.record_label.grid(column=1, row=0, sticky=tk.W+tk.E)
        self.record_tree.grid(column=1, row=1, sticky=tk.W+tk.E+tk.N+tk.S)

        self.root.grid_columnconfigure(0, minsize=300)
        self.root.grid_columnconfigure(1, weight=1, minsize=500)
        self.root.grid_rowconfigure(1, weight=1) 
Example #16
Source File: SymbolBrowser.py    From halucinator with GNU General Public License v3.0 6 votes vote down vote up
def set_layout(self):
        '''
            Sets the layout for the gui
        '''
        s = ttk.Style()
        s.theme_use('clam')

        # Layout column 0
        self.table_funcs.grid(column=0, row=0, sticky=tk.W+tk.E)
        self.tree.grid(column=0, row=1, sticky=tk.W+tk.E+tk.N+tk.S)

        # Layout column 1
        self.record_label.grid(column=1, row=0, sticky=tk.W+tk.E)
        self.record_tree.grid(column=1, row=1, sticky=tk.W+tk.E+tk.N+tk.S)

        self.root.grid_columnconfigure(0, minsize=300)
        self.root.grid_columnconfigure(1, weight=1, minsize=500)
        self.root.grid_rowconfigure(1, weight=1) 
Example #17
Source File: app.py    From QM-Simulator-1D with MIT License 6 votes vote down vote up
def set_potential_sliders(self) -> None:
        """
        Set the sliders for the parameters that control
        the potential function.
        """
        for i in range(len(self.V_params)):
            self.sliders2.append(
                tk.Scale(self.window, 
                         label="change %s: " % str(self.V_params[i][0]),
                         from_=-2, to=2,
                         resolution=0.01,
                         orient=tk.HORIZONTAL,
                         length=200,
                         command=self.update_potential_by_slider
                         )
            )
            self.sliders2[i].grid(
                row=17 + self.sliders2_count + self.sliders1_count, 
                column=3, columnspan=2, 
                sticky=tk.N+tk.W+tk.E, padx=(10, 10)
            )
            self.sliders2[i].set(self.V_params[i][1])
            self.sliders2_count += 1 
Example #18
Source File: chapter8_04.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 6 votes vote down vote up
def __init__(self, path):
        super().__init__()
        self.title("Ttk Treeview")

        abspath = os.path.abspath(path)
        self.nodes = {}
        self.tree = ttk.Treeview(self)
        self.tree.heading("#0", text=abspath, anchor=tk.W)
        ysb = ttk.Scrollbar(self, orient=tk.VERTICAL,
                            command=self.tree.yview)
        xsb = ttk.Scrollbar(self, orient=tk.HORIZONTAL,
                            command=self.tree.xview)
        self.tree.configure(yscroll=ysb.set, xscroll=xsb.set)

        self.tree.grid(row=0, column=0, sticky=tk.N + tk.S + tk.E + tk.W)
        ysb.grid(row=0, column=1, sticky=tk.N + tk.S)
        xsb.grid(row=1, column=0, sticky=tk.E + tk.W)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        self.tree.bind("<<TreeviewOpen>>", self.open_node)
        self.populate_node("", abspath) 
Example #19
Source File: chapter8_03.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 6 votes vote down vote up
def __init__(self, path):
        super().__init__()
        self.title("Ttk Treeview")

        columns = ("#1", "#2", "#3")
        self.tree = ttk.Treeview(self, show="headings", columns=columns)
        self.tree.heading("#1", text="Last name")
        self.tree.heading("#2", text="First name")
        self.tree.heading("#3", text="Email")
        ysb = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.tree.yview)
        self.tree.configure(yscroll=ysb.set)

        with open("contacts.csv", newline="") as f:
            for contact in csv.reader(f):
                self.tree.insert("", tk.END, values=contact)
        self.tree.bind("<<TreeviewSelect>>", self.print_selection)

        self.tree.grid(row=0, column=0)
        ysb.grid(row=0, column=1, sticky=tk.N + tk.S)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1) 
Example #20
Source File: gui.py    From hdfm with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, root, label, row, col):
        tkinter.Frame.__init__(self, root, bg='#cecece')
        # Set non-zero weight.
        root.columnconfigure(col, weight=1)
        root.rowconfigure(row, weight=1)
        # Information being displayed.
        self.label_text = label
        self.info = ''
        # Set up label.
        text = '{0}: {1}'.format(self.label_text, self.info)
        self.label = tkinter.Label(
            self,
            text=text,
            bg='#cecece'
        )
        self.label.place(relx=0.5, rely=0.5, anchor='c')
        # Position frame.
        self.grid(
            row=row,
            column=col,
            sticky=tkinter.N + tkinter.S + tkinter.E + tkinter.W
        )

    # Update info. 
Example #21
Source File: preview.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, available_masks, has_predicted_mask, selected_color,
                 selected_mask_type, selected_scaling, config_tools, patch_callback,
                 refresh_callback, tk_vars):
        logger.debug("Initializing %s: (available_masks: %s, has_predicted_mask: %s, "
                     "selected_color: %s, selected_mask_type: %s, selected_scaling: %s, "
                     "patch_callback: %s, refresh_callback: %s, tk_vars: %s)",
                     self.__class__.__name__, available_masks, has_predicted_mask, selected_color,
                     selected_mask_type, selected_scaling, patch_callback, refresh_callback,
                     tk_vars)
        self._config_tools = config_tools

        super().__init__(parent)
        self.pack(side=tk.LEFT, anchor=tk.N, fill=tk.Y)
        self._options = ["color", "mask_type", "scaling"]
        self._busy_tkvar = tk_vars["busy"]
        self._tk_vars = dict()

        d_locals = locals()
        defaults = {opt: self._format_to_display(d_locals["selected_{}".format(opt)])
                    for opt in self._options}
        self._busy_indicator = self._build_frame(defaults,
                                                 refresh_callback,
                                                 patch_callback,
                                                 available_masks,
                                                 has_predicted_mask) 
Example #22
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def _color_control(self):
        """ Clickable label holding the currently selected color """
        logger.debug("Add control to Options Frame: (widget: '%s', control: %s, choices: %s)",
                     self.option.name, self.option.control, self.option.choices)
        frame = ttk.Frame(self.frame)
        ctl = tk.Frame(frame,
                       bg=self.option.default,
                       bd=2,
                       cursor="hand2",
                       relief=tk.SUNKEN,
                       width=round(int(20 * get_config().scaling_factor)),
                       height=round(int(12 * get_config().scaling_factor)))
        ctl.bind("<Button-1>", lambda *e, c=ctl, t=self.option.title: self._ask_color(c, t))
        ctl.pack(side=tk.LEFT, anchor=tk.W)
        lbl = ttk.Label(frame, text=self.option.title, width=self.label_width, anchor=tk.W)
        lbl.pack(padx=2, pady=5, side=tk.RIGHT, anchor=tk.N)
        frame.pack(side=tk.LEFT, anchor=tk.W)
        if self.option.helptext is not None:
            _get_tooltip(lbl, text=self.option.helptext, wraplength=600)
        logger.debug("Added control to Options Frame: %s", self.option.name)
        return ctl 
Example #23
Source File: slider_gallery_frame.py    From pubgheatmap with MIT License 6 votes vote down vote up
def __init__(self, root, imagesList, final_img_size):
        super(SliderGalleryFrame, self).__init__(root)
        self.master.minsize(width=100, height=100)
        self.master.config()

        self.master.bind('<Left>', self.left_key)
        self.master.bind('<Right>', self.right_key)

        self.main_frame = tk.Frame()
        self.main_frame.pack(fill='both', expand=True)

        self.imagesList = imagesList

        self.panel = tk.Label(root, image=self.imagesList[0])
        self.panel.pack(side="bottom", fill="both", expand="yes")

        self.var = tk.IntVar()
        self.scale = tk.Scale(root, from_=0, to=len(imagesList) - 1, variable=self.var, orient=tk.HORIZONTAL,
                         command=self.sel, width=20, length=final_img_size)
        self.scale.pack(anchor=tk.N)

        self.pack() 
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_central_area(self):
        self.editor = Editor.Editor(self.master,
                set_status_text=self.set_status_text,
                font=self.create_font(), maxundo=0, undo=True,
                wrap=tk.WORD)
        self.editor.grid(row=1, column=1, sticky=(tk.N, tk.S, tk.W, tk.E),
                padx=PAD, pady=PAD)
        self.editor.text.bind("<<Selection>>", self.on_selection)
        self.editor.text.bind("<<Modified>>", self.on_modified)
        self.editor.text.bind("<KeyRelease>", self.on_moved, "+")
        self.editor.text.bind("<ButtonRelease>", self.on_moved, "+")
        self.editor.text.focus() 
Example #25
Source File: Dialog.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def __create_ui(self):
        widget = self.body(self)
        if isinstance(widget, (tuple, list)):
            body, focusWidget = widget
        else:
            body = focusWidget = widget
        self.initialFocusWidget = focusWidget
        buttons = self.button_box(self)
        body.grid(row=0, column=0, sticky=(tk.N, tk.S, tk.W, tk.E))
        buttons.grid(row=1, column=0)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1) 
Example #26
Source File: command.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        logger.debug("Initializing %s: (command: '%s')", self.__class__.__name__, parent.command)
        super().__init__(parent)
        self.pack(fill=tk.BOTH, padx=5, pady=5, side=tk.BOTTOM, anchor=tk.N)

        self.command = parent.command
        self.title = self.command.title()

        self.add_action_button(parent.category,
                               parent.actionbtns)
        logger.debug("Initialized %s", self.__class__.__name__) 
Example #27
Source File: display_analysis.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, selected_id, helptext):
        logger.debug("Initializing: %s: (parent, %s, selected_id: %s, helptext: '%s')",
                     self.__class__.__name__, parent, selected_id, helptext)
        super().__init__(parent)
        self.pack(side=tk.TOP, padx=5, pady=5, fill=tk.BOTH, expand=True)
        self.session = None  # set when loading or clearing from parent
        self.thread = None  # Thread for loading data popup
        self.selected_id = selected_id
        self.popup_positions = list()

        self.canvas = tk.Canvas(self, bd=0, highlightthickness=0)
        self.canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)

        self.tree_frame = ttk.Frame(self.canvas)
        self.tree_canvas = self.canvas.create_window((0, 0), window=self.tree_frame, anchor=tk.NW)
        self.sub_frame = ttk.Frame(self.tree_frame)
        self.sub_frame.pack(side=tk.LEFT, fill=tk.X, anchor=tk.N, expand=True)

        self.add_label()
        self.tree = ttk.Treeview(self.sub_frame, height=1, selectmode=tk.BROWSE)
        self.scrollbar = ttk.Scrollbar(self.tree_frame, orient="vertical", command=self.tree.yview)
        self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)

        self.columns = self.tree_configure(helptext)
        self.canvas.bind("<Configure>", self.resize_frame)
        logger.debug("Initialized: %s", self.__class__.__name__) 
Example #28
Source File: Help.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_ui(self):
        self.helpLabel = ttk.Label(self, text=_TEXT, background="white",
                justify=tk.CENTER)
        self.closeButton = TkUtil.Button(self, text="Close", underline=0)
        self.helpLabel.pack(anchor=tk.N, expand=True, fill=tk.BOTH,
                padx=PAD, pady=PAD, ipadx="2m", ipady="2m")
        self.closeButton.pack(anchor=tk.S)
        self.protocol("WM_DELETE_WINDOW", self.close)
        if not TkUtil.mac():
            self.bind("<Alt-c>", self.close)
        self.bind("<Escape>", self.close)
        self.bind("<Expose>", self.reposition) 
Example #29
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def build_control_label(self):
        """ Label for control """
        logger.debug("Build control label: (option: '%s')", self.option.name)
        lbl = ttk.Label(self.frame, text=self.option.title, width=self.label_width, anchor=tk.W)
        lbl.pack(padx=5, pady=5, side=tk.LEFT, anchor=tk.N)
        if self.option.helptext is not None:
            _get_tooltip(lbl, text=self.option.helptext, wraplength=600)
        logger.debug("Built control label: (widget: '%s', title: '%s'",
                     self.option.name, self.option.title) 
Example #30
Source File: TextEdit.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master=None, **kwargs):
        super().__init__(master)
        self.frame = self
        self.text = tk.Text(self, **kwargs)
        self.xscrollbar = TkUtil.Scrollbar.Scrollbar(self,
                command=self.text.xview, orient=tk.HORIZONTAL)
        self.yscrollbar = TkUtil.Scrollbar.Scrollbar(self,
                command=self.text.yview, orient=tk.VERTICAL)
        self.text.configure(yscrollcommand=self.yscrollbar.set,
                xscrollcommand=self.xscrollbar.set)
        self.xscrollbar.grid(row=1, column=0, sticky=(tk.W, tk.E))
        self.yscrollbar.grid(row=0, column=1, sticky=(tk.N, tk.S))
        self.text.grid(row=0, column=0, sticky=(tk.N, tk.S, tk.W, tk.E))
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)