Python tkinter.S Examples

The following are 30 code examples of tkinter.S(). 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: Main.py    From python-in-practice with GNU General Public License v3.0 7 votes vote down vote up
def create_statusbar(self):
        statusBar = ttk.Frame(self.master)
        statusLabel = ttk.Label(statusBar, textvariable=self.statusText)
        statusLabel.grid(column=0, row=0, sticky=(tk.W, tk.E))
        self.modifiedLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.modifiedLabel.grid(column=1, row=0, pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.modifiedLabel,
                text="MOD if the text has unsaved changes")
        self.positionLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.positionLabel.grid(column=2, row=0, sticky=(tk.W, tk.E),
                pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.positionLabel,
                text="Current line and column position")
        ttk.Sizegrip(statusBar).grid(row=0, column=4, sticky=(tk.S, tk.E))
        statusBar.columnconfigure(0, weight=1)
        statusBar.grid(row=2, column=0, columnspan=3, sticky=(tk.W, tk.E))
        self.set_status_text("Start typing to create a new document or "
                "click File→Open") 
Example #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def create_statusbar(self):
        statusBar = ttk.Frame(self.master)
        statusLabel = ttk.Label(statusBar, textvariable=self.statusText)
        statusLabel.grid(column=0, row=0, sticky=(tk.W, tk.E))
        self.modifiedLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.modifiedLabel.grid(column=1, row=0, pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.modifiedLabel,
                text="MOD if the text has unsaved changes")
        self.positionLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.positionLabel.grid(column=2, row=0, sticky=(tk.W, tk.E),
                pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.positionLabel,
                text="Current line and column position")
        ttk.Sizegrip(statusBar).grid(row=0, column=4, sticky=(tk.S, tk.E))
        statusBar.columnconfigure(0, weight=1)
        statusBar.grid(row=2, column=0, columnspan=3, sticky=(tk.W, tk.E))
        self.set_status_text("Start typing to create a new document or "
                "click File→Open") 
Example #12
Source File: text_for_weights_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def create_widgets(self, weight_name):
        ''' Creates all widgets.
        '''
        constraints_lbl = Label(
            self, text='Enter {0} weight restrictions:'.format(
                weight_name))
        constraints_lbl.grid(padx=10, pady=2, sticky=N+W)
        examples_lbl = Label(self, text='e.g. {0}'.format(self.examples))
        examples_lbl.grid(row=1, column=0, padx=10, pady=5, sticky=N+W)

        errors_lbl = Label(self, textvariable=self.errors_strvar, 
                           foreground='red', anchor=W, justify=LEFT, 
                           wraplength=80)
        errors_lbl.grid(row=2, column=2, sticky=N+W, padx=5, pady=5)

        self.grid_rowconfigure(2, weight=1)
        self.grid_columnconfigure(0, weight=1)

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

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

        self.text = Text(self, wrap=NONE, width=TEXT_WIDTH_VAL,
                         height=TEXT_HEIGHT_VAL,
                         xscrollcommand=xscrollbar.set,
                         yscrollcommand=yscrollbar.set)

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

        xscrollbar.config(command=self.text.xview)
        yscrollbar.config(command=self.text.yview) 
Example #13
Source File: data_tab_frame_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def create_widgets(self, current_categories,
                       str_var_for_input_output_boxes):
        ''' Creates widgets on this frame.

            Args:
                current_categories (list of str): list of current categories
                    (might be empty).
                str_var_for_input_output_boxes (ObserverStringVar): object
                    that contains current
                    input and output categories and notifies table with data
                    when data is loaded
                    and some categories need to be checked.
        '''
        self.rowconfigure(1, weight=1)
        self.columnconfigure(0, weight=1)

        self._create_btns()
        self._create_label_frame()

        table = TableFrameWithInputOutputBox(self.panel, self.params_frame,
                                             self.params_frame.options_frame.
                                             combobox_text_var,
                                             current_categories,
                                             str_var_for_input_output_boxes,
                                             self.if_text_modified_str,
                                             self.data)
        self.table = table
        table.grid(sticky=E+W+S+N, padx=5, pady=5)

        frame_for_navigation_btns = NavigationForTableFrame(self, table)
        table_modifier_frame = TableModifierFrame(self, self.table,
                                                  self.clear_all_on_btn_click,
                                                  frame_for_navigation_btns.
                                                  set_navigation)
        table_modifier_frame.grid(row=1, column=1, sticky=N, pady=15, padx=5)
        self.table_modifier_frame = table_modifier_frame

        frame_for_navigation_btns.grid(row=2, column=0, sticky=E, pady=5,
                                       padx=5)
        self.navigation_frame = frame_for_navigation_btns 
Example #14
Source File: categories_checkbox_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def create_widgets(self):
        ''' Creates widgets of this object.
        '''
        yScrollbar = Scrollbar(self, orient=VERTICAL)
        yScrollbar.grid(row=2, column=3, sticky=N+S)

        canvas = StyledCanvas(self, height=HEIGHT_WITHOUT_CHECKBOXES,
                              yscrollcommand=yScrollbar.set)
        self.canvas = canvas
        canvas.grid(row=2, column=0, columnspan=3, sticky=N+E+W)

        self._config_columns(self)
        canvas.columnconfigure(0, weight=1)

        if self.add_headers:
            non_discr_lbl = Label(self, text='Non-\ndiscretionary')
            non_discr_lbl.grid(row=0, column=1, padx=3, pady=1)
            weakly_disp_lbl = Label(self, text='Weakly\ndisposable')
            weakly_disp_lbl.grid(row=0, column=2, padx=3, pady=1)
            sep = Separator(self)
            sep.grid(row=1, column=0, columnspan=3, sticky=E+W, pady=10, padx=3)

        self.frame_with_boxes = Frame(canvas)
        self._config_columns(self.frame_with_boxes)
        self.frame_with_boxes.grid(sticky=N+S+W+E, pady=15, padx=3)

        canvas.create_window(0, 0, window=self.frame_with_boxes, anchor=N+W)
        canvas.update_idletasks()

        canvas['scrollregion'] = (0, 0, 0, HEIGHT_WITHOUT_CHECKBOXES)
        yScrollbar['command'] = canvas.yview

        MouseWheel(self).add_scrolling(canvas, yscrollbar=yScrollbar) 
Example #15
Source File: solution_tab_frame_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def create_widgets(self):
        ''' Creates appropriate widgets on this frame.
        '''
        self.columnconfigure(0, weight=1)
        self.rowconfigure(3, weight=1)
        frame_for_save_btn = Frame(self)
        frame_for_save_btn.columnconfigure(1, weight=1)
        self.status_lbl = Label(frame_for_save_btn, text='')
        self.status_lbl.grid(row=0, column=1, sticky=N+W)
        save_solution_btn = Button(frame_for_save_btn, text='Save solution',
                                   command=self.on_save_solution)
        save_solution_btn.grid(row=1, column=0, sticky=W+N, padx=5, pady=5)
        self.progress_bar = Progressbar(frame_for_save_btn,
                                        mode='determinate', maximum=100)
        self.progress_bar.grid(row=1, column=1, sticky=W+E, padx=10, pady=5)

        frame_for_save_btn.grid(sticky=W+N+E+S, padx=5, pady=5)

        frame_for_btns = Frame(self)
        self._create_file_format_btn('*.xlsx', 1, frame_for_btns, 0)
        self._create_file_format_btn('*.xls', 2, frame_for_btns, 1)
        self._create_file_format_btn('*.csv', 3, frame_for_btns, 2)
        self.solution_format_var.set(1)

        frame_for_btns.grid(row=1, column=0, sticky=W+N+E+S, padx=5, pady=5)
        self.data_from_file_lbl = Label(self, text=TEXT_FOR_FILE_LBL, anchor=W,
                                        justify=LEFT,
                                        wraplength=MAX_FILE_PARAMS_LBL_LENGTH)
        self.data_from_file_lbl.grid(row=2, column=0, padx=5, pady=5,
                                     sticky=W+N)

        self.solution_tab = SolutionFrameWithText(self)
        self.solution_tab.grid(row=3, column=0, sticky=W+E+S+N, padx=5, pady=5) 
Example #16
Source File: table_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def create_widgets(self):
        ''' Creates all widgets.
        '''
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        yScrollbar = Scrollbar(self, orient=VERTICAL)
        yScrollbar.grid(row=0, column=1, sticky=N+S)
        xScrollbar = Scrollbar(self, orient=HORIZONTAL)
        xScrollbar.grid(row=1, column=0, sticky=E+W)

        canvas = StyledCanvas(self, yscrollcommand=yScrollbar.set,
                              xscrollcommand=xScrollbar.set, bd=0)
        self.canvas = canvas
        canvas.grid(row=0, column=0, sticky=N+S+W+E)

        frame_with_table = Frame(canvas)
        self.frame_with_table = frame_with_table
        frame_with_table.grid(sticky=N+S+W+E, pady=15, padx=3)

        for i in range(2, self.nb_rows + 2):
            cols = []
            for j in range(1, self.nb_cols + 1):
                ent = self.create_entry_widget(frame_with_table)
                ent.grid(row=i, column=j, sticky=N+S+E+W)
                cols.append(ent)
            self.cells.append(cols)

        canvas.create_window(0, 0, window=frame_with_table, anchor='nw')
        canvas.update_idletasks()

        yScrollbar['command'] = canvas.yview
        xScrollbar['command'] = canvas.xview
        self._update_scroll_region()

        MouseWheel(self).add_scrolling(canvas, yscrollbar=yScrollbar) 
Example #17
Source File: main_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def create_widgets(self):
        ''' Creates all widgets that belong to this frame.
        '''
        self.parent.title('pyDEA')
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(0, weight=1, pad=5)
        self.columnconfigure(1, weight=0, pad=5)
        self.rowconfigure(0, pad=3, weight=1)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)

        self.current_categories = []
        data_from_params_file = StringVar()
        str_var_for_input_output_boxes = ObserverStringVar()
        self.params_frame = ParamsFrame(self, self.current_categories,
                                        data_from_params_file,
                                        str_var_for_input_output_boxes,
                                        self.weights_status_str)
        data_frame = DataFrame(self, self.params_frame, self.current_categories,
                               data_from_params_file,
                               str_var_for_input_output_boxes)
        self.data_frame = data_frame
        data_frame.grid(row=0, column=0, sticky=N+S+W+E, padx=15, pady=15)

        self.params_frame.grid(row=0, column=1, sticky=W+E+S+N, padx=15,
                               pady=15, columnspan=2)

        lbl_progress = Label(self, text='Progress')
        lbl_progress.grid(row=1, column=0, sticky=W, padx=10, pady=5)

        self.progress_bar = Progressbar(self, mode='determinate', maximum=100)
        self.progress_bar.grid(row=2, column=0, sticky=W+E, padx=10, pady=5)

        run_btn = Button(self, text='Run', command=self.run)
        run_btn.grid(row=2, column=1, sticky=W, padx=10, pady=10)

        self.weights_status_lbl = Label(self, text='', foreground='red')
        self.weights_status_lbl.grid(row=2, column=2, padx=10, pady=5, sticky=W) 
Example #18
Source File: table_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def add_row(self):
        ''' Adds one row to the end of the table.
        '''
        self.cells.append([])
        for j in range(self.nb_cols):
            grid_row_index = self.nb_rows + 2
            ent = self.create_entry_widget(self.frame_with_table)
            ent.grid(row=grid_row_index, column=j + 1, sticky=N+S+E+W)
            self.cells[self.nb_rows].append(ent)
        self.nb_rows += 1
        self._update_scroll_region() 
Example #19
Source File: table_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def add_column(self):
        ''' Adds one column to the end of the table.
        '''
        for i in range(self.nb_rows):
            grid_row_index = i + 2
            ent = self.create_entry_widget(self.frame_with_table)
            ent.grid(row=grid_row_index, column=self.nb_cols + 1,
                     sticky=N+S+E+W)
            self.cells[i].append(ent)
        self.nb_cols += 1
        self._update_scroll_region() 
Example #20
Source File: gridframe.py    From copycat with MIT License 5 votes vote down vote up
def add(self, element, x, y, xspan=1, yspan=1):
        element.grid(column=x, row=y, columnspan=xspan, rowspan=yspan, sticky=tk.N+tk.E+tk.S+tk.W)
        tk.Grid.rowconfigure(self, x, weight=1)
        tk.Grid.columnconfigure(self, y, weight=1) 
Example #21
Source File: pncview.py    From pseudonetcdf with GNU Lesser General Public License v3.0 5 votes vote down vote up
def gettime(ifile):
    from PseudoNetCDF import PseudoNetCDFVariable
    from datetime import datetime, timedelta
    if 'time' in ifile.variables:
        time = ifile.variables['time']
        unit = time.units
        tunit, datestr = unit.split(' since ')
        sdate = datetime.strptime(datestr.replace(
            ' UTC', ''), '%Y-%m-%d %H:%M:%S')
        time = np.array([sdate + timedelta(**{tunit: t}) for t in time[:]])
        unit = 'time'
    elif 'TFLAG' in ifile.variables:
        x = ifile.variables['TFLAG'][:].copy()
        for axi in range(1, x.ndim - 1):
            x = x[:, 0]
        time = np.array(
            [(datetime.strptime('%07d %06d' % (d, t), '%Y%j %H%M%S'))
             for d, t in x])
        unit = 'time'
    elif 'time' in ifile.dimensions:
        time = np.arange(len(ifile.dimensions['time']))
        unit = 'steps'
    elif 'TSTEP' in ifile.dimensions:
        time = np.arange(1, len(ifile.dimensions['TSTEP']) + 1)
        unit = 'steps'
    else:
        raise KeyError('No time found')
    return PseudoNetCDFVariable(None, 'time', 'f', ('time',),
                                values=time[:], units=unit) 
Example #22
Source File: preview.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def _build_frame(self, defaults, refresh_callback, patch_callback,
                     available_masks, has_predicted_mask):
        """ Build the :class:`ActionFrame`.

        Parameters
        ----------
        defaults: dict
            The default command line options
        patch_callback: python function
            The function to execute when a patch callback is received
        refresh_callback: python function
            The function to execute when a refresh callback is received
        available_masks: list
            The available masks that exist within the alignments file
        has_predicted_mask: bool
            Whether the model was trained with a mask

        Returns
        -------
        ttk.Progressbar
            A Progress bar to indicate that the Preview tool is busy
        """
        logger.debug("Building Action frame")

        bottom_frame = ttk.Frame(self)
        bottom_frame.pack(side=tk.BOTTOM, fill=tk.X, anchor=tk.S)
        top_frame = ttk.Frame(self)
        top_frame.pack(side=tk.TOP, fill=tk.BOTH, anchor=tk.N, expand=True)

        self._add_cli_choices(top_frame, defaults, available_masks, has_predicted_mask)

        busy_indicator = self._add_busy_indicator(bottom_frame)
        self._add_refresh_button(bottom_frame, refresh_callback)
        self._add_patch_callback(patch_callback)
        self._add_actions(bottom_frame)
        logger.debug("Built Action frame")
        return busy_indicator 
Example #23
Source File: review_filtered_clips.py    From youtube-gesture-dataset with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def make_label(self):
        self.tx_vid_name = tk.Label(self.top_frame, bg='#8C8C8C', text='No selected video')
        self.tx_clip_interval = tk.Label(self.top_frame, bg='#8C8C8C', text='No selected clip')
        self.tx_vid_name.grid(row=0, column=0, sticky=(tk.N + tk.S + tk.E + tk.W))
        self.tx_clip_interval.grid(row=1, column=0, sticky=(tk.N + tk.S + tk.E + tk.W)) 
Example #24
Source File: review_filtered_clips.py    From youtube-gesture-dataset with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def make_view_combobox(self):
        self.mode = tk.StringVar()
        self.view_combo = ttk.Combobox(self.top_frame, values=('ALL', 'TRUE', 'FALSE'), textvariable=self.mode)
        self.view_combo.grid(row=2, column=0, sticky=(tk.N + tk.S + tk.E + tk.W), padx=5, pady=5)
        self.view_combo.current(0)
        self.view_combo.bind('<<ComboboxSelected>>', self.OnComboSelected) 
Example #25
Source File: calendarwidget.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def __place_widgets(self):
        # header frame and its widgets
        hframe = ttk.Frame(self)
        lbtn = ttk.Button(hframe, command=self._prev_month, text="Previous")
        rbtn = ttk.Button(hframe, command=self._next_month, text="Next")
        self._header = ttk.Label(hframe, width=15, anchor='center')
        # the calendar
        self._calendar = ttk.Treeview(self, show='', selectmode='none', height=7)

        # pack the widgets
        hframe.pack(side='top', pady=4, anchor='center')
        lbtn.grid(sticky=tk.N + tk.S + tk.W + tk.E)
        self._header.grid(column=1, row=0, padx=12)
        rbtn.grid(column=2, row=0, sticky=tk.N + tk.S + tk.W + tk.E)
        self._calendar.pack(expand=1, fill='both', side='bottom') 
Example #26
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_file_menu(self):
        modifier = TkUtil.menu_modifier()
        self.fileMenu = tk.Menu(self.menubar, name="apple")
        self.fileMenu.add_command(label=NEW, underline=0,
                command=self.new, image=self.menuImages[NEW],
                compound=tk.LEFT, accelerator=modifier + "+N")
        self.fileMenu.add_command(label=OPEN + ELLIPSIS, underline=0,
                command=self.open, image=self.menuImages[OPEN],
                compound=tk.LEFT, accelerator=modifier + "+O")
        self.fileMenu.add_cascade(label=OPEN_RECENT,
                underline=5, image=self.menuImages[OPEN],
                compound=tk.LEFT)
        self.fileMenu.add_command(label=SAVE, underline=0,
                command=self.save, image=self.menuImages[SAVE],
                compound=tk.LEFT, accelerator=modifier + "+S")
        self.fileMenu.add_command(label=SAVE_AS + ELLIPSIS, underline=5,
                command=self.save_as, image=self.menuImages[SAVEAS],
                compound=tk.LEFT)
        if TkUtil.mac():
            self.master.createcommand("::tk::mac::ShowPreferences",
                    self.preferences)
            self.master.createcommand("exit", self.close)
        else:
            self.fileMenu.add_separator()
            self.fileMenu.add_command(label=PREFERENCES + ELLIPSIS,
                    underline=0, image=self.menuImages[PREFERENCES],
                    compound=tk.LEFT, command=self.preferences)
            self.fileMenu.add_separator()
            self.fileMenu.add_command(label=QUIT, underline=0,
                    command=self.close, compound=tk.LEFT,
                    image=self.menuImages[QUIT],
                    accelerator=modifier + "+Q")
        self.menubar.add_cascade(label="File", underline=0,
                menu=self.fileMenu)


    # NOTE: the Tkinter API doesn't seem to let us check whether redo is
    # possible (so here we always leave Redo enabled). 
Example #27
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 #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")
        self.closeButton = TkUtil.Button(self, text="Close", underline=0)
        self.helpLabel.pack(anchor=tk.N, expand=True, fill=tk.BOTH,
                padx=PAD, pady=PAD)
        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: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_dock_areas(self):
        self.leftDockArea = ttk.Frame(self.master)
        self.rightDockArea = ttk.Frame(self.master)
        self.leftDockArea.grid(row=1, column=0, sticky=(tk.N, tk.S))
        self.leftDockArea.grid_remove()
        self.rightDockArea.grid(row=1, column=2, sticky=(tk.N, tk.S))
        self.rightDockArea.grid_remove() 
Example #30
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()