Python tkinter.CENTER Examples

The following are 30 code examples of tkinter.CENTER(). 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: window.py    From LPHK with GNU General Public License v3.0 8 votes vote down vote up
def popup(self, window, title, image, text, button_text, end_command=None):
        popup = tk.Toplevel(window)
        popup.resizable(False, False)
        if MAIN_ICON != None:
            if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
                dummy = None
                #popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
            else:
                popup.iconbitmap(MAIN_ICON)
        popup.wm_title(title)
        popup.tkraise(window)

        def run_end():
            popup.destroy()
            if end_command != None:
                end_command()

        picture_label = tk.Label(popup, image=image)
        picture_label.photo = image
        picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
        tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, padx=10, pady=10)
        tk.Button(popup, text=button_text, command=run_end).grid(column=1, row=1, padx=10, pady=10)
        popup.wait_visibility()
        popup.grab_set()
        popup.wait_window() 
Example #2
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 #3
Source File: chapter8_07.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 7 votes vote down vote up
def create_header(self):
        left_arrow = {'children': [('Button.leftarrow', None)]}
        right_arrow = {'children': [('Button.rightarrow', None)]}
        style = ttk.Style(self)
        style.layout('L.TButton', [('Button.focus', left_arrow)])
        style.layout('R.TButton', [('Button.focus', right_arrow)])

        hframe = ttk.Frame(self)
        btn_left = ttk.Button(hframe, style='L.TButton',
                              command=lambda: self.move_month(-1))
        btn_right = ttk.Button(hframe, style='R.TButton',
                               command=lambda: self.move_month(1))
        label = ttk.Label(hframe, width=15, anchor='center')

        hframe.pack(pady=5, anchor=tk.CENTER)
        btn_left.grid(row=0, column=0)
        label.grid(row=0, column=1, padx=12)
        btn_right.grid(row=0, column=2)
        return label 
Example #4
Source File: ticketbox.py    From hwk-mirror with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, parent, **kwargs):
        super().__init__(parent,
                bd=7,
                bg="white smoke",
                **kwargs)

        tk.Frame(self,width=340,
                height=340).grid(sticky="nswe")
        self.info_label = tk.Message(self,
                font=self.font,
                anchor=tk.CENTER,
                bg="white smoke",
                width=1000)
        self.comments = tk.Label(self, 
                justify=tk.LEFT,
                font=self.comment_font,
                width=20,
                bg="white smoke")

        self.info_label.grid(row=0, column=0, sticky="nswe")
        self.comments.grid(row=1, column=0, sticky="nse")
        self.ticket = None 
Example #5
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 #6
Source File: window.py    From LPHK with GNU General Public License v3.0 6 votes vote down vote up
def popup_choice(self, window, title, image, text, choices):
        popup = tk.Toplevel(window)
        popup.resizable(False, False)
        if MAIN_ICON != None:
            if os.path.splitext(MAIN_ICON)[1].lower() == ".gif":
                dummy = None
                #popup.call('wm', 'iconphoto', popup._w, tk.PhotoImage(file=MAIN_ICON))
            else:
                popup.iconbitmap(MAIN_ICON)
        popup.wm_title(title)
        popup.tkraise(window)
        
        def run_end(func):
            popup.destroy()
            if func != None:
                func()

        picture_label = tk.Label(popup, image=image)
        picture_label.photo = image
        picture_label.grid(column=0, row=0, rowspan=2, padx=10, pady=10)
        tk.Label(popup, text=text, justify=tk.CENTER).grid(column=1, row=0, columnspan=len(choices), padx=10, pady=10)
        for idx, choice in enumerate(choices):
            run_end_func = partial(run_end, choice[1])
            tk.Button(popup, text=choice[0], command=run_end_func).grid(column=1 + idx, row=1, padx=10, pady=10)
        popup.wait_visibility()
        popup.grab_set()
        popup.wait_window() 
Example #7
Source File: graph_canvas.py    From networkx_viewer with GNU General Public License v3.0 6 votes vote down vote up
def _draw_node(self, coord, data_node):
        """Create a token for the data_node at the given coordinater"""
        (x,y) = coord
        data = self.dataG.node[data_node]

        # Apply filter to node to make sure we should draw it
        for filter_lambda in self._node_filters:
            try:
                draw_flag = eval(filter_lambda, {'u':data_node, 'd':data})
            except Exception as e:
                self._show_filter_error(filter_lambda, e)
                return
            # Filters are applied as an AND (ie, all must be true)
            # So if one is false, exit
            if draw_flag == False:
                return

        # Create token and draw node
        token = self._NodeTokenClass(self, data, data_node)
        id = self.create_window(x, y, window=token, anchor=tk.CENTER,
                                  tags='node')
        self.dispG.add_node(id, {'dataG_id': data_node,
                                 'token_id': id, 'token': token})
        return id 
Example #8
Source File: program3.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):     # constructor method
        # define list of label texts
        self.greet_list = ('Hello, World! This is python GUI.', \
                           'Hello, This is Python GUI. Sadly, I was made to say Hello only. I will love to say so much more.')
        
        # creat label as a child of root window with some text.
        self.label = ttk.Label(master, text = self.greet_list[0])
        
        self.btn = ttk.Button(master, text = 'Greet Again', command = self.handle_text) # create a button
        
        # store image in the label obj to keep it in the scope as 
        # long as label is displayed and to avoid getting the image getting garbage collected
        imgpath = 'simple_gif.gif'                                      # path of the image
        self.label.img = tk.PhotoImage(file = imgpath)                  # read_image :: saving image within label_object to prevent its garbage collection
        self.label.config(image = self.label.img)                       # display image in label widget
        self.label.config(compound = 'left')                            # to display image in left of text
        
        self.label.pack()                                               # pack label to the window with pack() geometry method of Label
        self.btn.pack()
        
        self.label.config(wraplength = 200)                             # specify wraplength of text in label
        self.label.config(justify = tk.CENTER)                          # justify text in label to (CENTER, RIGHT or LEFT)
        self.label.config(foreground = 'blue', background = 'yellow')   # insert font color (foreground) and background color
        self.label.config(font = ('Times', 10, 'bold'))                 # font = (font_name, font_size, font_type) 
Example #9
Source File: order_display.py    From hwk-mirror with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master, **kwargs):
        super().__init__(master, "Options", 
                bd=2, width=8,
                relief=tk.FLAT, anchor=tk.CENTER,
                **kwargs) 
Example #10
Source File: Editor.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master, set_status_text=report, **kwargs):
        super().__init__(master, **kwargs)
        self.set_status_text = set_status_text
        self.filename = None
        for justify in (tk.LEFT, tk.CENTER, tk.RIGHT):
            self.text.tag_configure(justify, justify=justify) 
Example #11
Source File: order_display.py    From hwk-mirror with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master, **kwargs):
        super().__init__(master,
                 text="", bd=2,
                 width=8, relief=tk.FLAT,
                 anchor=tk.CENTER, **kwargs)
        self.command = self._command
        self.item = None 
Example #12
Source File: main_gui.py    From JAVER_Assist with MIT License 5 votes vote down vote up
def __tab1_content(self, tab_name):
        dir_section = tk.LabelFrame(tab_name, text='请输入目录信息', background=self.__BG_GREY, font=self.__FONT)
        dir_section.place(x=10, y=10, width=880, height=480)

        tk.Label(dir_section, text='待整理路径:', background=self.__BG_GREY,
                 font=self.__FONT).place(x=2, y=10, width=110, height=30)
        prepare_label = tk.Label(dir_section, background=self.__WHITE, relief='solid', anchor='w',
                                 borderwidth=1, font=self.__FONT)
        prepare_label.place(x=112, y=10, width=600, height=30)
        tk.Button(dir_section, text='选择输入路径', justify=tk.CENTER, font=self.__FONT,
                  command=lambda: self.__get_path(prepare_label)).place(x=720, y=10, width=150, height=30)

        tk.Label(dir_section, text='输出文件夹:', background=self.__BG_GREY,
                 font=self.__FONT).place(x=2, y=60, width=110, height=30)
        output_label = tk.Label(dir_section, background=self.__WHITE, relief='solid', anchor='nw',
                                borderwidth=1, font=self.__FONT)
        output_label.place(x=112, y=60, width=600, height=30)
        tk.Button(dir_section, text='选择输出路径', justify=tk.CENTER, font=self.__FONT,
                  command=lambda: self.__get_path(output_label)).place(x=720, y=60, width=150, height=30)

        tk.Button(dir_section, text='开始整理', justify=tk.CENTER, font=self.__FONT,
                  command=lambda: self.__start_running(prepare_label['text'],
                                                       output_label['text'])).place(x=10, y=110, width=150, height=30)

        attention = '请务必确认路径选择正确,不然可能会造成数据丢失的严重后果!!!'
        tk.Label(dir_section, text=attention, background=self.__BG_GREY, font=("Microsoft YaHei", 10),
                 anchor='w', foreground="#222222", ).place(x=180, y=110, width=500, height=30)

        tk.Label(dir_section, text='信息和日志:', background=self.__BG_GREY, font=self.__FONT,
                 justify=tk.RIGHT).place(x=2, y=160, width=110, height=30)

        info = scrolledtext.ScrolledText(dir_section)
        info.place(x=10, y=200, width=860, height=250)
        info.insert(tk.INSERT, "Some text")
        info.insert(tk.INSERT, "asfasdfsadfsadfsadfsadf")
        info.insert(tk.INSERT, "Some text\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
        info.insert(tk.END, " in ScrolledText")
        info.config(state=tk.DISABLED) 
Example #13
Source File: box.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, master, title):
        self.title = title
        super().__init__(master, text=title, padding=4)
        self.player = None   # will be connected later
        self.volumeVar = tk.DoubleVar(value=100)
        self.volumefilter = VolumeFilter()
        ttk.Label(self, text="title / artist / album").pack()
        self.titleLabel = ttk.Label(self, relief=tk.GROOVE, width=22, anchor=tk.W)
        self.titleLabel.pack()
        self.artistLabel = ttk.Label(self, relief=tk.GROOVE, width=22, anchor=tk.W)
        self.artistLabel.pack()
        self.albumlabel = ttk.Label(self, relief=tk.GROOVE, width=22, anchor=tk.W)
        self.albumlabel.pack()
        f = ttk.Frame(self)
        ttk.Label(f, text="time left: ").pack(side=tk.LEFT)
        self.timeleftLabel = ttk.Label(f, relief=tk.GROOVE, anchor=tk.CENTER)
        self.timeleftLabel.pack(side=tk.RIGHT, fill=tk.X, expand=True)
        f.pack(fill=tk.X)
        f = ttk.Frame(self)
        ttk.Label(f, text="V: ").pack(side=tk.LEFT)
        scale = ttk.Scale(f, from_=0, to=150, length=120, variable=self.volumeVar, command=self.on_volumechange)
        scale.bind("<Double-1>", self.on_dblclick_vol)
        scale.pack(side=tk.LEFT)
        self.volumeLabel = ttk.Label(f, text="???%")
        self.volumeLabel.pack(side=tk.RIGHT)
        f.pack(fill=tk.X)
        ttk.Button(self, text="Skip", command=lambda s=self: s.player.skip(s)).pack(pady=4)
        self.volume = 100
        self.stateLabel = tk.Label(self, text="STATE", relief=tk.SUNKEN, border=1)
        self.stateLabel.pack()
        self._track = None
        self._time = None
        self._stream = None
        self._state = self.state_needtrack
        self.state = self.state_needtrack
        self.xfade_state = self.state_xfade_nofade
        self.xfade_started = None
        self.xfade_start_volume = None
        self.playback_started = None
        self.track_duration = None 
Example #14
Source File: box.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.config_location = appdirs.user_data_dir("PythonJukebox", "Razorvine")
        os.makedirs(self.config_location, mode=0o700, exist_ok=True)
        for family in tk.font.names():
            font = tk.font.nametofont(family)
            font["size"] = abs(font["size"]) + 1
            if family != "TkFixedFont":
                font["family"] = "helvetica"
        self.title("Jukebox   |   synthplayer lib v" + synthplayer.__version__)
        f = ttk.Frame()
        f1 = ttk.Frame(f)
        self.firstTrackFrame = TrackFrame(f1, "Track 1")
        self.secondTrackFrame = TrackFrame(f1, "Track 2")
        self.levelmeterFrame = LevelmeterFrame(f1)
        self.playlistFrame = PlaylistFrame(self, f1)
        self.firstTrackFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.secondTrackFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.levelmeterFrame.pack(side=tk.LEFT, fill=tk.Y)
        self.playlistFrame.pack(side=tk.LEFT, fill=tk.Y)
        f1.pack(side=tk.TOP)
        f2 = ttk.Frame(f)
        self.searchFrame = SearchFrame(self, f2)
        self.searchFrame.pack()
        f2.pack(side=tk.TOP)
        f3 = ttk.Frame(f)
        optionsFrame = ttk.Frame(f3)
        ttk.Button(optionsFrame, text="Database Config", command=self.do_database_config).pack()
        optionsFrame.pack(side=tk.LEFT)
        self.effectsFrame = EffectsFrame(self, f3)
        self.effectsFrame.pack()
        f3.pack(side=tk.TOP)
        self.statusbar = ttk.Label(f, text="<status>", relief=tk.GROOVE, anchor=tk.CENTER)
        self.statusbar.pack(fill=tk.X, expand=True)
        f.pack()
        self.player = Player(self, (self.firstTrackFrame, self.secondTrackFrame))
        self.backend = None
        self.backend_process = None
        self.show_status("Connecting to backend file service...")
        self.after(500, self.connect_backend) 
Example #15
Source File: wrapper.py    From MindMap with MIT License 5 votes vote down vote up
def init_pages():
	global tk_sheets

	# destroy any sheets in list so that we can update it (ex. after deletion)
	for s in tk_sheets:
		s.destroy()


	font_colour = toHex(shadeN([cs.background, cs.lightText], [0,1], cs.fontOpacity))

	

	tk_sheets=[]

	sheets_info = get_sheet_list()

	for s in sheets_info:
		s_box = tk.Label(tk_root, text=s['name'], font=settings.FONT, bg=toHex(cs.background), fg=font_colour, cursor='hand1', anchor=tk.CENTER)
		s_box.bind('<Button-1>', lambda event, filename=s['filename']: sheetClick(filename, event))
		s_box.bind('<Button-3>', lambda event, sheet=s: sheetRightClick(sheet, event))

		s_box.bind('<Enter>', lambda event, sheet=s_box: labelEnter(sheet, event))
		s_box.bind('<Leave>', lambda event, sheet=s_box: labelLeave(sheet, event))
		
		tk_sheets.append(s_box)

	s_box_plus = tk.Label(tk_root, text='+', font=settings.FONT, bg=toHex(cs.background), fg=font_colour, cursor='hand1', anchor=tk.CENTER)
	s_box_plus.bind('<Button-1>', addFile)
	s_box_plus.bind('<Enter>', lambda event, sheet=s_box_plus: labelEnter(sheet, event))
	s_box_plus.bind('<Leave>', lambda event, sheet=s_box_plus: labelLeave(sheet, event))
	
	tk_sheets.append(s_box_plus)

	resize_layout() 
Example #16
Source File: matrixMenu.py    From Raspberry-Pi-3-Cookbook-for-Python-Programmers-Third-Edition with MIT License 5 votes vote down vote up
def __init__(self,parent,matrix):
    self.parent = parent
    self.matrix=matrix
    #Light Status
    self.lightStatus=0
    #Add a canvas area ready for drawing on
    self.canvas = TK.Canvas(parent, width=WINDOW_W,
                        height=WINDOW_H, background=colBg)
    self.canvas.pack()
    #Add some "lights" to the canvas
    self.light = []
    for iy in range(NUM_BUTTON):
      for ix in range(NUM_BUTTON):
        x = MARGIN+MARGIN+((MARGIN+BUTTON_SIZE)*ix)
        y = MARGIN+MARGIN+((MARGIN+BUTTON_SIZE)*iy)
        self.light.append(self.canvas.create_rectangle(x,y,
                              x+BUTTON_SIZE,y+BUTTON_SIZE,
                              fill=LIGHTOFFON[OFF]))
    #Add other items
    self.codeText=TK.StringVar()
    self.codeText.trace("w", self.changedCode)
    self.generateCode()
    code=TK.Entry(parent,textvariable=self.codeText,
                  justify=TK.CENTER,width=TEXT_WIDTH)
    code.pack()
    #Bind to canvas not tk (only respond to lights)
    self.canvas.bind('<Button-1>', self.mouseClick) 
Example #17
Source File: display_analysis.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def add_label(self):
        """ Add tree-view Title """
        logger.debug("Adding Treeview title")
        lbl = ttk.Label(self.sub_frame, text="Session Stats", anchor=tk.CENTER)
        lbl.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5) 
Example #18
Source File: display_analysis.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def add_section(frame, title):
        """ Add a separator and section title """
        sep = ttk.Frame(frame, height=2, relief=tk.SOLID)
        sep.pack(fill=tk.X, pady=(5, 0), side=tk.TOP)
        lbl = ttk.Label(frame, text=title)
        lbl.pack(side=tk.TOP, padx=5, pady=0, anchor=tk.CENTER) 
Example #19
Source File: zynthian_gui_controller.py    From zynthian-ui with GNU General Public License v3.0 5 votes vote down vote up
def plot_value_rectangle(self):
		self.calculate_plot_values()
		x1=6
		y1=self.height-5
		lx=self.trw-4
		ly=2*self.trh
		y2=y1-ly

		if self.max_value>0:
			x2=x1+lx*self.value_plot/self.max_value
		else:
			x2=x1

		if self.rectangle:
				self.canvas.coords(self.rectangle,(x1, y1, x2, y2))
		elif self.zctrl.midi_cc!=0:
			self.rectangle_bg=self.canvas.create_rectangle((x1, y1, x1+lx, y2), fill=zynthian_gui_config.color_ctrl_bg_off, width=0)
			self.rectangle=self.canvas.create_rectangle((x1, y1, x2, y2), fill=zynthian_gui_config.color_ctrl_bg_on, width=0)
			self.canvas.tag_lower(self.rectangle_bg)
			self.canvas.tag_lower(self.rectangle)

		if self.value_text:
			self.canvas.itemconfig(self.value_text, text=value_print)
		else:
			self.value_text=self.canvas.create_text(x1+self.trw/2-1, y1-self.trh, width=self.trw,
				justify=CENTER,
				fill=zynthian_gui_config.color_ctrl_tx,
				font=(zynthian_gui_config.font_family,self.value_font_size),
				text=self.value_print) 
Example #20
Source File: zynthian_gui_controller.py    From zynthian-ui with GNU General Public License v3.0 5 votes vote down vote up
def plot_value_triangle(self):
		self.calculate_plot_values()
		x1=2
		y1=int(0.8*self.height)+self.trh

		if self.max_value>0:
			x2=x1+self.trw*self.value_plot/self.max_value
			y2=y1-self.trh*self.value_plot/self.max_value
		else:
			x2=x1
			y2=y1

		if self.triangle:
				#self.canvas.coords(self.triangle_bg,(x1, y1, x1+self.trw, y1, x1+self.trw, y1-self.trh))
				self.canvas.coords(self.triangle,(x1, y1, x2, y1, x2, y2))
		elif self.zctrl.midi_cc!=0:
			self.triangle_bg=self.canvas.create_polygon((x1, y1, x1+self.trw, y1, x1+self.trw, y1-self.trh), fill=zynthian_gui_config.color_ctrl_bg_off)
			self.triangle=self.canvas.create_polygon((x1, y1, x2, y1, x2, y2), fill=zynthian_gui_config.color_ctrl_bg_on)
			self.canvas.tag_lower(self.triangle_bg)
			self.canvas.tag_lower(self.triangle)

		if self.value_text:
			self.canvas.itemconfig(self.value_text, text=self.value_print)
		else:
			self.value_text=self.canvas.create_text(x1+self.trw/2-1, y1-self.trh-8, width=self.trw,
				justify=CENTER,
				fill=zynthian_gui_config.color_ctrl_tx,
				font=(zynthian_gui_config.font_family,self.value_font_size),
				text=self.value_print) 
Example #21
Source File: zynthian_gui_controller.py    From zynthian-ui with GNU General Public License v3.0 5 votes vote down vote up
def plot_value_arc(self):
		self.calculate_plot_values()
		thickness=1.1*zynthian_gui_config.font_size
		degmax=300
		deg0=90+degmax/2

		if self.max_value!=0:
			degd=-degmax*self.value_plot/self.max_value
		else:
			degd=0

		if (not self.arc and self.zctrl.midi_cc!=0) or not self.value_text:
			x1=0.18*self.trw
			y1=self.height-int(0.7*self.trw)-6
			x2=x1+int(0.7*self.trw)
			y2=self.height-6

		if self.arc:
			self.canvas.itemconfig(self.arc, extent=degd)
		elif self.zctrl.midi_cc!=0:
			self.arc=self.canvas.create_arc(x1, y1, x2, y2, 
				style=tkinter.ARC,
				outline=zynthian_gui_config.color_ctrl_bg_on,
				width=thickness,
				start=deg0,
				extent=degd)
			self.canvas.tag_lower(self.arc)

		if self.value_text:
			self.canvas.itemconfig(self.value_text, text=self.value_print)
		else:
			self.value_text=self.canvas.create_text(x1+(x2-x1)/2-1, y1-(y1-y2)/2, width=x2-x1,
				justify=tkinter.CENTER,
				fill=zynthian_gui_config.color_ctrl_tx,
				font=(zynthian_gui_config.font_family,self.value_font_size),
				text=self.value_print) 
Example #22
Source File: zynthian_gui_controller.py    From zynthian-ui with GNU General Public License v3.0 5 votes vote down vote up
def plot_midi_bind(self, midi_cc, color=zynthian_gui_config.color_ctrl_tx):
		if not self.midi_bind:
			self.midi_bind = self.canvas.create_text(
				self.width/2,
				self.height-8,
				width=int(3*0.9*zynthian_gui_config.font_size),
				justify=tkinter.CENTER,
				fill=color,
				font=(zynthian_gui_config.font_family,int(0.7*zynthian_gui_config.font_size)),
				text=str(midi_cc))
		else:
			self.canvas.itemconfig(self.midi_bind, text=str(midi_cc), fill=color) 
Example #23
Source File: voyagerimb.py    From voyagerimb with MIT License 5 votes vote down vote up
def __init__(self, parent):
        self.parent = parent
        self.browser = parent.browser
        self.frame = tk.LabelFrame(self.parent.frame, text=" Plot scanline ")
        self.scale = tk.Scale(self.frame, from_=0, to=self.browser.number_of_scans,
                              orient=tk.HORIZONTAL, showvalue=True, command=self.model_sync_with_entry )
        self.scale.pack(side=tk.LEFT, fill=tk.X, padx=4, pady=4, anchor=tk.CENTER, expand=True)
        self.parent.numberofscans.number_of_scans_entry.textvariable.trace("w", self.model_slide_range_update)
        tk.Button(self.frame, text="-", command=self.model_decrease).pack(side=tk.LEFT)
        tk.Button(self.frame, text="+", command=self.model_increase).pack(side=tk.LEFT)
        self.frame.pack(side=tk.TOP, fill=tk.X, padx=7, pady=7, expand=False) 
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_view_menu(self):
        modifier = TkUtil.menu_modifier()
        viewMenu = tk.Menu(self.menubar)
        viewMenu.add_checkbutton(label=BOLD, underline=0,
                image=self.menuImages[BOLD], compound=tk.LEFT,
                variable=self.bold,
                command=lambda: self.toggle_button(self.boldButton))
        viewMenu.add_checkbutton(label=ITALIC, underline=0,
                image=self.menuImages[ITALIC], compound=tk.LEFT,
                variable=self.italic,
                command=lambda: self.toggle_button(self.italicButton))
        viewMenu.add_separator()
        viewMenu.add_radiobutton(label=ALIGN_LEFT, underline=6,
                image=self.menuImages[ALIGNLEFT], compound=tk.LEFT,
                variable=self.alignment, value=tk.LEFT,
                command=self.toggle_alignment)
        viewMenu.add_radiobutton(label=ALIGN_CENTER, underline=6,
                image=self.menuImages[ALIGNCENTER],
                compound=tk.LEFT, variable=self.alignment, value=tk.CENTER,
                command=self.toggle_alignment)
        viewMenu.add_radiobutton(label=ALIGN_RIGHT, underline=6,
                image=self.menuImages[ALIGNRIGHT],
                compound=tk.LEFT, variable=self.alignment, value=tk.RIGHT,
                command=self.toggle_alignment)
        self.menubar.add_cascade(label="View", underline=0,
                menu=viewMenu) 
Example #25
Source File: propertiesframe.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master=None, callback=None, label=True, fontsize=11, **kwargs):
        """
        Create a FontPropertiesFrame.
        
        :param master: master widget
        :type master: widget
        :param callback: callback with argument
                         (`bool` bold, `bool` italic, `bool` underline, `bool` overstrike)
        :type callback: function
        :param label: show a header label
        :type label: str
        :param fontsize: size of the font on the buttons
        :type fontsize: int
        :param kwargs: keyword arguments passed on to the :class:`ttk.Frame` initializer
        """
        ttk.Frame.__init__(self, master, **kwargs)
        self._style = ttk.Style()
        self.__label = label
        self.__callback = callback
        self._header_label = ttk.Label(self, text="Font properties:")
        self._style.configure("Bold.Toolbutton", font=("default", fontsize, "bold"), anchor=tk.CENTER)
        self._style.configure("Italic.Toolbutton", font=("default", fontsize, "italic"), anchor=tk.CENTER)
        self._style.configure("Underline.Toolbutton", font=("default", fontsize, "underline"), anchor=tk.CENTER)
        self._style.configure("Overstrike.Toolbutton", font=("default", fontsize, "overstrike"), anchor=tk.CENTER)
        self._bold = tk.BooleanVar()
        self._italic = tk.BooleanVar()
        self._underline = tk.BooleanVar()
        self._overstrike = tk.BooleanVar()
        self._bold_button = ttk.Checkbutton(self, style="Bold.Toolbutton", text="B", width=2, command=self._on_click,
                                            variable=self._bold)
        self._italic_button = ttk.Checkbutton(self, style="Italic.Toolbutton", text="I", width=2,
                                              command=self._on_click, variable=self._italic)
        self._underline_button = ttk.Checkbutton(self, style="Underline.Toolbutton", text="U", width=2,
                                                 command=self._on_click, variable=self._underline)
        self._overstrike_button = ttk.Checkbutton(self, style="Overstrike.Toolbutton", text="O", width=2,
                                                  command=self._on_click, variable=self._overstrike)
        self._grid_widgets() 
Example #26
Source File: chooser.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, master=None, **kwargs):
        """
        Create a FontChooser.
        
        :param master: master window
        :type master: widget
        :param kwargs: keyword arguments passed to :class:`tk.Toplevel` initializer
        """
        tk.Toplevel.__init__(self, master, **kwargs)
        self.wm_title("Choose a font")
        self.resizable(False, False)
        self.style = ttk.Style()
        self.style.configure("FontChooser.TLabel", font=("default", 11), relief=tk.SUNKEN, anchor=tk.CENTER)
        self._font_family_header = ttk.Label(self, text="Font family", style="FontChooser.TLabel")
        self._font_family_list = FontFamilyListbox(self, callback=self._on_family, height=8)
        self._font_label_variable = tk.StringVar()
        self._font_label = ttk.Label(self, textvariable=self._font_label_variable, background="white")
        self._font_properties_header = ttk.Label(self, text="Font properties", style="FontChooser.TLabel")
        self._font_properties_frame = FontPropertiesFrame(self, callback=self._on_properties, label=False)
        self._font_size_header = ttk.Label(self, text="Font size", style="FontChooser.TLabel")
        self._size_dropdown = FontSizeDropdown(self, callback=self._on_size, width=4)
        self._example_label = tk.Label(self, text="Example", anchor=tk.CENTER, background="white", height=2,
                                       relief=tk.SUNKEN)

        self._family = None
        self._size = 11
        self._bold = False
        self._italic = False
        self._underline = False
        self._overstrike = False
        self._font = None
        self._ok_button = ttk.Button(self, text="OK", command=self._close)
        self._cancel_button = ttk.Button(self, text="Cancel", command=self._cancel)
        self._grid_widgets() 
Example #27
Source File: About.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_tags(self):
        self.text.tag_config("center", justify=tk.CENTER)
        self.text.tag_config("url", underline=True)
        self.text.tag_bind("url", "<Double-Button-1>", self.handle_url) 
Example #28
Source File: GameOver.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def body(self, master):
        frame = ttk.Frame(master)
        if self.won:
            message = "You won with a score of {:,}!"
            if self.newHighScore:
                message += "\nThat's a new high score!"
        else:
            message = "Game over with a score of {:,}."
        label = ttk.Label(frame, text=message.format(self.score),
                justify=tk.CENTER)
        label.pack(fill=tk.BOTH, padx="7m", pady="4m")
        frame.pack(fill=tk.BOTH)
        return frame 
Example #29
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 #30
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def context_menu(self, event):
        modifier = TkUtil.menu_modifier()
        menu = tk.Menu(self.master)
        if self.editor.text.tag_ranges(tk.SEL):
            menu.add_command(label=COPY, underline=0,
                    command=lambda: self.editor.text.event_generate(
                        "<<Copy>>"), image=self.menuImages[COPY],
                    compound=tk.LEFT, accelerator=modifier + "+C")
            menu.add_command(label=CUT, underline=2,
                    command=lambda: self.editor.text.event_generate(
                        "<<Cut>>"), image=self.menuImages[CUT],
                    compound=tk.LEFT, accelerator=modifier + "+X")
        menu.add_command(label=PASTE, underline=0,
                command=lambda: self.editor.text.event_generate(
                    "<<Paste>>"), image=self.menuImages[PASTE],
                compound=tk.LEFT, accelerator=modifier + "+V")
        menu.add_separator()
        menu.add_checkbutton(label=BOLD, underline=0,
                image=self.menuImages[BOLD], compound=tk.LEFT,
                variable=self.bold,
                command=lambda: self.toggle_button(self.boldButton))
        menu.add_checkbutton(label=ITALIC, underline=0,
                image=self.menuImages[ITALIC], compound=tk.LEFT,
                variable=self.italic,
                command=lambda: self.toggle_button(self.italicButton))
        menu.add_separator()
        menu.add_radiobutton(label=ALIGN_LEFT, underline=6,
                image=self.menuImages[ALIGNLEFT], compound=tk.LEFT,
                variable=self.alignment, value=tk.LEFT,
                command=self.toggle_alignment)
        menu.add_radiobutton(label=ALIGN_CENTER, underline=6,
                image=self.menuImages[ALIGNCENTER],
                compound=tk.LEFT, variable=self.alignment, value=tk.CENTER,
                command=self.toggle_alignment)
        menu.add_radiobutton(label=ALIGN_RIGHT, underline=6,
                image=self.menuImages[ALIGNRIGHT],
                compound=tk.LEFT, variable=self.alignment, value=tk.RIGHT,
                command=self.toggle_alignment)
        menu.tk_popup(event.x_root, event.y_root)