def lables(self): ''' displays the labels on the main page''' font.nametofont('TkDefaultFont').configure(size=15) MyFont = font.Font(size=20)#Changes the font size self.labelItems = Label(root,text="Items", font=MyFont) self.labelItems.configure(background='white') self.labelItems.pack() self.labelType = Label(root,text="Type") self.labelType.configure(background='white') self.labelType.place(x=100,y=80) self.labelTime = Label(root,text="Time") self.labelTime.configure(background='white') self.labelTime.place(x=100,y=160) self.labelSearching = Label(root,text="Searching") self.labelSearching.configure(background='white') self.labelSearching.place(x=60,y=240) self.labelSorting = Label(root,text="Sorting") self.labelSorting.configure(background='white') self.labelSorting.place(x=80,y=320) self.lableRobotColour = Label(root,text= "Robots colour") self.lableRobotColour.configure(background='white') self.lableRobotColour.place(x=185,y=400)
def getFont(labelType): """ User fonts settings @type labelType: LabelType @param labelType: type of the label """ if labelType == LabelType.NORMAL_TEXT: return ("Helvetica", 11) elif labelType == LabelType.LABEL_FRAME_TITLE: return ("Helvetica", 11) elif labelType == LabelType.TITEL_TEXT: return ("Helvetica", 13, "bold") elif labelType == LabelType.RADIO_BUTTON: #return ("Helvetica", 11) default_font = tkFont.nametofont("TkDefaultFont") font = (default_font['family'], default_font['size'] + 2, default_font['weight']) #font.configure(size=12) return font elif labelType == LabelType.LISTBOX: default_font = tkFont.nametofont("TkDefaultFont") return default_font return ("Helvetica", 14)
def deck_options(self,decknum): if not self.deckopt: self.deckopt = Toplevel(self) self.deckopt.resizable(0,0) self.deckopt.protocol('WM_DELETE_WINDOW', self.close_deck_opt) self.current_deckopt_num = decknum-1 custom_title = Label(self.deckopt,text="Deck %i options:"%decknum,font=tkFont.nametofont("TkTextFont")) custom_title.grid(row=0,column=0) self.deckopt_button = Button(self.deckopt, text="Deck %i enabled"%decknum,font=self.mediumfont, command=self.config_deckbutton) self.deckopt_button.grid(row=1,column=0) if self.current_deckopt_num in defines.DECKS_TO_USE: self.deckopt_button.configure(background="#00ff00",text="Deck %i Enabled "%decknum) else: self.deckopt_button.configure(background="#ff0000",text="Deck %i Disabled"%decknum) self.target = IntVar() self.target.set(defines.TARGETING[self.current_deckopt_num]) Label(self.deckopt,text="Targeting preference:", font=tkFont.nametofont("TkTextFont")).grid(row=2,column=0,sticky=W) Radiobutton(self.deckopt, text="No targeting", font=tkFont.nametofont("TkTextFont"), variable=self.target, value=0, command=self.config_preferences).grid(row=3,column=0,sticky=W) Radiobutton(self.deckopt, text="Opponent hero", font=tkFont.nametofont("TkTextFont"), variable=self.target, value=1, command=self.config_preferences).grid(row=4,column=0,sticky=W) #Radiobutton(self.deckopt, text="Enemy taunt minion", font=tkFont.nametofont("TkTextFont"), variable=self.target, value=2, command=self.config_preferences).grid(row=5,column=0,sticky=W) #Radiobutton(self.deckopt, text="Random friendly minion", font=tkFont.nametofont("TkTextFont"), variable=self.target, value=3, command=self.config_preferences).grid(row=6,column=0,sticky=W) else: self.close_deck_opt() self.deck_options(decknum)
def initialize_font(): if "Open Sans" in tkFont.families(): default_font = tkFont.nametofont("TkDefaultFont") default_font.configure(family="Open Sans", size=11) default_font = tkFont.nametofont("TkTextFont") default_font.configure(family="Open Sans", size=11)
def create_main_window(): global main_window main_window = Tk() tkFont.nametofont('TkDefaultFont').configure(size=12) main_window.protocol('WM_DELETE_WINDOW', quit) main_window.title('Прошивки') main_window.resizable(False, False) i = 0 buttons = [] for dir in os.listdir(settings.FIRMWARE_PATH): if os.path.isdir(os.path.join(settings.FIRMWARE_PATH, dir)) and dir != '$tmp$': buttons.append(Button(main_window, text=dir)) buttons[i].bind('<Button-1>', main_window_onclick) buttons[i].pack(fill='both') i += 1 buttons.append( Button(main_window, text='Загрузить с сервера', command=create_ftp_window)) buttons[len(buttons) - 1].pack(fill='both', pady=(10, 0)) buttons.append(Button(main_window, text='Выход', command=quit)) buttons[len(buttons) - 1].pack(fill='both') main_window.update_idletasks() main_window.geometry(position(main_window)) main_window.update_idletasks() main_window.mainloop()
def __init__(self, master, text, title): self.master = master dlg = self.dlg = tk.Toplevel(master) self.dlg.withdraw() #hiden window dlg.title(title) dlg.minsize(600,400) # Text self.text = tk.Text(dlg, height=1) self.text['font'] = font.nametofont('TkFixedFont') self.text.insert(tk.END, text) # Make text read-only self.text['state'] = tk.DISABLED self.text.pack(fill=tk.BOTH, expand=1, padx=4, pady=4) # Frame for buttons self.frame = tk.Frame(dlg) self.frame.pack(padx=2, pady=2) # Button self.btn_accept = tk.Button(self.frame, text='< Ok >', command=self.accept) self.btn_accept['font'] = font.nametofont('TkFixedFont') self.btn_accept.pack(side=tk.LEFT, padx=2) # Bind Enter and Esc keys self.dlg.bind('<Return>', self.accept) self.dlg.bind('<Escape>', self.cancel) # Modal dialog dlg.transient(master) dlg.grab_set() # Center dialog window _center_window_above_parent(master, dlg) self.dlg.deiconify() # show window # Focus entry field self.text.focus_set()
def labels(self): ''' displays the labels on the main page''' font.nametofont('TkDefaultFont').configure(size=15) MyFont = font.Font(size=20) #Changes the font size self.labelItems = Label(root, text="Items", font=MyFont) self.labelItems.configure(background='white') self.labelItems.pack() self.labelType = Label(root, text="Type") self.labelType.configure(background='white') self.labelType.place(x=100, y=80) self.labelTime = Label(root, text="Time") self.labelTime.configure(background='white') self.labelTime.place(x=100, y=160) self.labelSearching = Label(root, text="Searching") self.labelSearching.configure(background='white') self.labelSearching.place(x=60, y=240) self.labelSorting = Label(root, text="Sorting") self.labelSorting.configure(background='white') self.labelSorting.place(x=80, y=320) self.lableRobotColour = Label(root, text="Robots colour") self.lableRobotColour.configure(background='white') self.lableRobotColour.place(x=185, y=400)
def __init__(self, variable_base=None, fixed_base=None): if variable_base is None: variable_base = tkFont.nametofont("TkDefaultFont") if fixed_base is None: fixed_base = tkFont.nametofont("TkFixedFont") self.default = self.clone_font(variable_base, "default") self.fixed = self.clone_font(fixed_base, "fixed") self._reset()
def __init__(self, master, text, title, ident=None, value=None): self.master = master dlg = self.dlg = tk.Toplevel(master) self.dlg.withdraw() #hiden window dlg.title(title) # Identifier label if ident is not None: self.label_id = tk.Label(dlg, anchor=tk.W, justify=tk.LEFT) self.label_id['font'] = font.nametofont('TkFixedFont') self.label_id['text'] = '# {}'.format(ident) self.label_id.pack(fill=tk.X, padx=2, pady=2) # Label self.label = tk.Label(dlg, anchor=tk.W, justify=tk.LEFT) self.label['font'] = font.nametofont('TkFixedFont') self.label['text'] = text self.label.pack(fill=tk.X, padx=10, pady=4) # Entry box self.entry = tk.Entry(dlg) self.entry['font'] = font.nametofont('TkFixedFont') self.entry.pack(fill=tk.X, padx=2, pady=2) # Frame for buttons self.frame = tk.Frame(dlg) self.frame.pack(padx=2, pady=2) # Button self.btn_accept = tk.Button(self.frame, text='< Ok >', command=self.accept) self.btn_accept['font'] = font.nametofont('TkFixedFont') self.btn_accept.pack(side=tk.LEFT, padx=2) self.btn_cancel = tk.Button(self.frame, text='< Cancel >', command=self.cancel) self.btn_cancel['font'] = font.nametofont('TkFixedFont') self.btn_cancel.pack(side=tk.LEFT, padx=2) # Bind Enter and Esc keys self.dlg.bind('<Return>', self.accept) self.dlg.bind('<Escape>', self.cancel) # Dialog is resizable only by width self.dlg.resizable(1, 0) # Set supplied value (if any) if value is not None: self.entry.insert(0, value) self.entry.selection_range(0, tk.END) # By default returned value is None. To caller this means that entry # process was cancelled self.value = None # Modal dialog dlg.transient(master) dlg.grab_set() # Center dialog window _center_window_above_parent(master, dlg) self.dlg.deiconify() # show window # Focus entry field self.entry.focus_set()
def __init__(self, parent): Frame.__init__(self, parent) self.parent = parent menubar = Menu(self.parent) self.parent.config(menu=menubar) self.mediumfont = tkFont.nametofont("TkFixedFont") self.mediumfont.configure(size=22) self.mediumfont.configure(family="Helvetica") optionsmenu = Menu(menubar, tearoff=0) optionsmenu.add_command(label="Custom Decks", command=self.select_decks_to_use) optionsmenu.add_command(label="Gameplay", command=self.misc) optionsmenu.add_command(label="Controls", command=self.controls) optionsmenu.add_command(label="Resolution", command=self.resolutions) optionsmenu.add_separator() optionsmenu.add_command(label="Exit", command=self.quit) menubar.add_cascade(label="Options", menu=optionsmenu) helpmenu = Menu(menubar, tearoff=0) helpmenu.add_command(label="Help", command=self.help_window) helpmenu.add_command(label="Donate Bitcoin!", command=self.donate_window) menubar.add_cascade(label="Help", menu=helpmenu) self._job_id = None self._error = "" self.parent.title(defines.titles[randint(0,len(defines.titles)-1)]) self.parent.resizable(0,0) default_font = tkFont.nametofont("TkDefaultFont") default_font.configure(size=42) self.led = Button(self,state='disabled') self.qmessage = Label(self,text="Edit the decks for the bot to use with Options->Custom_Decks before starting",font=tkFont.nametofont("TkTextFont")) self.start_button = Button(self, text="start", command=self.start_click) self.stop_button = Button(self, text="stop", command=self.stop_click) self.start_button.grid(row=1,column=0,sticky='N') self.stop_button.grid(row=1,column=1,sticky='N') self.led.grid(row=1,column=2) self.qmessage.grid(row=0,column=0,columnspan=3) self.change_led_color("#ff0000"," off ") self.stop_button.config(state='disabled') self.deckopt=False self.deckwin=False self.queue = Queue.Queue() self.logicthread = GameLogicThread(self.queue)
def __init__(self, master, text, background=None, font=None, familiy=None, size=None, underline=True, visited_fg = "#551A8B", normal_fg = "#0000EE", visited=False, action=None): self._visited_fg = visited_fg self._normal_fg = normal_fg if visited: fg = self._visited_fg else: fg = self._normal_fg if font is None: default_font = nametofont("TkDefaultFont") family = default_font.cget("family") if size is None: size = default_font.cget("size") font = Font(family=family, size=size, underline=underline) Label.__init__(self, master, text=text, fg=fg, cursor="hand2", font=font) if background is None: background = get_background_of_widget(master) self.configure(background=background) self._visited = visited self._action = action self.bind("<Button-1>", self._on_click)
def __init__(self, parent): """ My constructor """ self.tk = Tk() #set min and preferred size of main gui self.minwinwidth = 300 self.minwinheight = 300 screen_width = self.winfo_screenwidth() screen_height = self.winfo_screenheight() self.preferwinwidth = int(screen_width * 0.8) self.preferwinheight = int(screen_height * 0.8) self.minsize(width=self.minwinwidth, height=self.minwinheight) self.geometry("{}x{}".format(self.preferwinwidth, self.preferwinheight)) #tweak the aspect ratio of the menu and data gui self.menuaspect = [1, 0.15] self.dataaspect = [1, 1 - 0.15] self.dpi = 80 #find exect dir self.execdir = __file__.split('zfit.py')[0] if (len(self.execdir) == 0): self.execdir = './' #Fiddle with font default_font = tkFont.nametofont("TkDefaultFont") default_font.configure(size=14) #init gui frame self.initialize()
def __init__(self, master, app, *kw, **kwargs): Listbox.__init__(self, master, *kw, **kwargs) self.bind("<Button-1>", self.button1) self.bind("<ButtonRelease-1>", self.release1) self.bind("<Double-1>", self.double) self.bind("<Return>", self.edit) self.bind("<KP_Enter>", self.edit) self.bind("<Insert>", self.insertItem) self.bind("<Control-Key-Return>", self.insertItem) self.bind("<Control-Key-space>", self.commandFocus) self.bind("<Delete>", self.deleteLine) self.bind("<BackSpace>", self.deleteLine) self.bind("<Control-Key-Up>", self.orderUp) self.bind("<Control-Key-Down>", self.orderDown) try: self.bind("<KP_Delete>", self.deleteLine) except: pass self.bind("<Control-Key-b>", self.insertBlock) self.bind("<Control-Key-r>", self.fill) self._blockPos = [] self._items = [] self.app = app self.gcode = app.gcode self.font = tkFont.nametofont(self.cget("font")) self._ystart = 0 self._double = False # double clicked handled self._hadfocus = False self.filter = None
def __init__(self, parent): """ My constructor """ self.tk = Tk() # set min and preferred size of main gui self.minwinwidth = 300 self.minwinheight = 300 screen_width = self.winfo_screenwidth() screen_height = self.winfo_screenheight() self.preferwinwidth = int(screen_width * 0.8) self.preferwinheight = int(screen_height * 0.8) self.minsize(width=self.minwinwidth, height=self.minwinheight) self.geometry("{}x{}".format(self.preferwinwidth, self.preferwinheight)) # tweak the aspect ratio of the menu and data gui self.menuaspect = [1, 0.15] self.dataaspect = [1, 1 - 0.15] self.dpi = 80 # find exect dir self.execdir = __file__.split("zfit.py")[0] if len(self.execdir) == 0: self.execdir = "./" # Fiddle with font default_font = tkFont.nametofont("TkDefaultFont") default_font.configure(size=14) # init gui frame self.initialize()
def zoom_in(self, event): """ Ctrl+= increases text size """ self.root.grid_propagate(False) font = tkFont.nametofont("CodeFont") size = font.actual()["size"] + 2 font.configure(size=size) return 'break'
def init_values(self): """Some values are loaded. Some for an initial .json-creation.""" #values of the menu itself self.protocol("WM_DELETE_WINDOW", self.on_closing) style = ttk.Style(self) style.theme_use('clam') self.default_font = tkFont.nametofont("TkDefaultFont") self.default_font.configure(size=11) self.option_add("*Font", self.default_font) self.main_color = self.cget('bg') self.red = "#BB2222" self.halfred = str(rgb.halfway(self.main_color, self.red)) self.quarred = str(rgb.halfway(self.main_color, self.halfred)) self.green = "#22BB22" self.halfgreen = str(rgb.halfway(self.main_color, self.green)) self.quargreen = str(rgb.halfway(self.main_color, self.halfgreen)) self.x_padding = 5 self.y_padding = 5 self.button_padding = 10 self.mark = tk.IntVar() self.mark.set(1) self.resizable(0, 0) #standard values of the picture and the weaving self.nailsx = 100 self.nailsy = 100 self.steps_done = 0 self.two_sided_nail = True self.color_scheme = "bw" self.steps = [] self.current_step = -1
def __init__(self,parent, startfile=None, z_start=0.0): """ My constructor """ self.tk = Tk() #set min and preferred size of main gui self.minwinwidth=300 self.minwinheight=300 screen_width = self.winfo_screenwidth() screen_height = self.winfo_screenheight() self.preferwinwidth=int(screen_width*0.8) self.preferwinheight=int(screen_height*0.8) self.minsize(width=self.minwinwidth, height=self.minwinheight) self.geometry("{}x{}".format(self.preferwinwidth,self.preferwinheight)) #tweak the aspect ratio of the menu and data gui self.menuaspect=[1,0.24] #Ruari 24/05 fixes bug where different resolutions cause the menu to be cut off self.dataaspect=[1,1-0.24] #Ruari 24/05 fixes bug where different resolutions cause the menu to be cut off self.dpi=80 #find exect dir self.execdir=__file__.split('zfit.py')[0] if(len(self.execdir)==0): self.execdir='./' #Fiddle with font default_font = tkfont.nametofont("TkDefaultFont") scalefont = int(screen_height/1080.0*14) default_font.configure(size=scalefont) #init gui frame self.initialize(startfile, z_start)
def __init__(self, parent): Frame.__init__(self, parent) Worker.__init__(self) self.customFont = tkFont.nametofont("TkDefaultFont") self.variables = {} self.pack() self.create_widgets()
def zoom_out(self, event): """ Ctrl+- decreases text size (minimum of 8) """ self.root.grid_propagate(False) font = tkFont.nametofont("CodeFont") size = max(8, font.actual()["size"] - 2) font.configure(size=size) return 'break'
def __init__(self): self.host = "192.168.11.1" self.user = "******" self.pas = "******" self.client = paramiko.SSHClient() self.client.load_system_host_keys() self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.client.connect(hostname=self.host, username=self.user, password=self.pas) stdin, stdout, stderr = self.client.exec_command( "source catkin_ws/devel/setup.bash") data = stdout.read() + stderr.read() self.window = Tk() self.window.title("Copter don't hurt me") self.window.geometry("600x500") self.button_passed = 0 self.default_font = font.nametofont("TkDefaultFont") self.default_font.configure(size=20) self.window.option_add("*Font", self.default_font) self.tab_control = ttk.Notebook(self.window) self.square_arr = []
def __init__(self, master, app, *kw, **kwargs): Listbox.__init__(self, master, *kw, **kwargs) self.bind("<Button-1>", self.button1) self.bind("<ButtonRelease-1>", self.release1) self.bind("<Double-1>", self.double) self.bind("<Return>", self.edit) self.bind("<KP_Enter>", self.edit) self.bind("<Insert>", self.insertItem) self.bind("<Control-Key-Return>",self.insertItem) self.bind("<Control-Key-space>",self.commandFocus) self.bind("<Delete>", self.deleteLine) self.bind("<BackSpace>", self.deleteLine) try: self.bind("<KP_Delete>",self.deleteLine) except: pass self.bind("<Control-Key-b>", self.insertBlock) self.bind("<Control-Key-r>", self.fill) self._blockPos = [] self._items = [] self.app = app self.gcode = app.gcode self.font = tkFont.nametofont(self.cget("font")) self._ystart = 0 self._double = False # double clicked handled self._hadfocus = False
def zoom_in(self, event): """ Ctrl+= increases text size """ self.root.grid_propagate(False) font = tkFont.nametofont("CodeFont") size = font.actual()["size"]+2 font.configure(size=size) return 'break'
def __init__(self, root, **kwargs): # Inherit Text.__init__(self, root, **kwargs) # Set font if SYSTEM == MAC_OS: fontfamily = "Monaco" elif SYSTEM == WINDOWS: fontfamily = "Consolas" else: fontfamily = "Courier New" self.font = tkFont.Font(family=fontfamily, size=10, name="ConsoleFont") self.font.configure(**tkFont.nametofont("ConsoleFont").configure()) self.configure(font="ConsoleFont") # Queue waits for messages to be added to the console self.queue = queue.Queue() # Don't allow keypresses self.bind("<Key>", self.null) self.colours = {} self.update_me()
def config_tags(self): """Get style defintions from the friendly local pygments formatter, and instantiate them as Tk.Text tag definitions.""" # Discover what 'basefont' currently in use curFontName = self.cget('font') curFont = tkFont.nametofont(curFontName) curFontSpecs = curFont.actual() basefont = ' '.join([ str(curFontSpecs[k]) for k in 'family size'.split() ]) # Get tag definitions from our pygments formatter styledict = self.formatter.get_style_defs() # Define our tags accordingly for tagName, attTupleList in styledict.iteritems(): # print "tagconfig:", tagName, tkatts for attTuple in attTupleList: (attName, attValue) = attTuple if attName == 'font': f = basefont.rsplit(' ', 1) f = (f[0], f[1], attValue) self.tag_configure(tagName, font = f) #self.tag_configure(tagName, font = basefont + ' ' + attValue) else: attSetter = dict([attTuple]) self.tag_configure(tagName, **attSetter)
def zoom_out(self, event): """ Ctrl+- decreases text size (minimum of 8) """ self.root.grid_propagate(False) font = tkFont.nametofont("CodeFont") size = max(8, font.actual()["size"]-2) font.configure(size=size) return 'break'
def __init__(self, repository, skein): "Initialize the skein window.setWindowNewMouseTool" self.sizedfont = tkFont.nametofont('TkDefaultFont').copy() self.skein = skein self.screenSize = skein.screenSize self.setrulingExtent(repository.pixelmagic.value) self.addCanvasMenuRootScrollSkein(repository, skein, '_skeinlayer', 'Skeinlayer') horizontalRulerBoundingBox = (0, 0, int( skein.screenSize.real ), self.rulingExtent) self.horizontalRulerCanvas = settings.Tkinter.Canvas(self.root, width = self.canvasWidth, height = self.rulingExtent, scrollregion=horizontalRulerBoundingBox) self.horizontalRulerCanvas.grid(row=1, column=2, columnspan=96, sticky=settings.Tkinter.E+settings.Tkinter.W) self.horizontalRulerCanvas['xscrollcommand'] = self.xScrollbar.set verticalRulerBoundingBox = (0, 0, self.rulingExtent, int(skein.screenSize.imag)) self.verticalRulerCanvas = settings.Tkinter.Canvas(self.root, width=self.rulingExtent, height=self.canvasHeight, scrollregion=verticalRulerBoundingBox) self.verticalRulerCanvas.grid(row=2, rowspan=96, column=1, sticky=settings.Tkinter.N+settings.Tkinter.S) self.verticalRulerCanvas['yscrollcommand'] = self.yScrollbar.set self.xStringVar = settings.Tkinter.StringVar(self.root) self.xLabel = settings.Tkinter.Label(self.root, textvariable=self.xStringVar, font = self.sizedfont) self.xLabel.grid(row=0, column=3, sticky=settings.Tkinter.W) self.yStringVar = settings.Tkinter.StringVar(self.root) self.yLabel = settings.Tkinter.Label(self.root, textvariable=self.yStringVar, font = self.sizedfont) self.yLabel.grid(row=0, column=4, sticky=settings.Tkinter.W) self.setWindowNewMouseTool(display_line.getNewMouseTool, repository.displayLine) self.setWindowNewMouseTool(view_move.getNewMouseTool, repository.viewMove) repository.showPosition.setUpdateFunction(self.setWindowToDisplaySaveUpdate) repository.widthOfExtrusionThread.setUpdateFunction(self.setWindowToDisplaySaveUpdate) self.addMouseToolsBind() self.createRulers()
def general_setting(self, root): sys.stdout.write("***general_setting\n") #print(tkFont.families()) default_font = tkFont.nametofont("TkDefaultFont") default_font.configure(family='微软雅黑', size=10) self.w = 800 self.h = 480 root.title('Main Window of ICO') #root.resizable(width=False, height=False) root.geometry('%dx%d+200+100' % (self.w, self.h)) # Set the minum size of the window root.minsize(self.w, self.h) # replace the tkinter ico #root.iconbitmap('c:\\test\\48X48_tk_logo.ico') #root.rowconfigure(0, weight=1) #root.columnconfigure(0, weight=1) # font to use for label widgets #root.option_add("*Font", "courier 12 bold") #root.option_add("*Button*Font", "courier 12 bold") #root.option_add("*Font", default_font) # make all widgets light blue root.option_add("*Background", "light blue") # use gold/black for selections root.option_add("*selectBackground", "gold") root.option_add("*selectForeground", "black") # the root window was already created, so we # have to update it ourselves root.config(background="light blue")
def zoom_in(self, event): """ Ctrl+= increases text size """ font = tkFont.nametofont("CodeFont") size = font.actual()["size"]+2 font.configure(size=size) return 'break'
def building_fonts(self): "building fonts" if not ON_PYTHON3: import tkFont else: from tkinter import font as tkFont self.title_font = tkFont.nametofont("TkCaptionFont") self.button_font = tkFont.Font(name="Helvetica", size=28)
def zoom_in(self, event): """ Ctrl+= increases text size """ font = tkFont.nametofont("CodeFont") size = font.actual()["size"] + 2 font.configure(size=size) return 'break'
def controls(self): self.controlwin = Toplevel(self) self.controlwin.resizable(0,0) custom_title = Label(self.controlwin,text="Control options:",font=tkFont.nametofont("TkTextFont")) custom_title.grid(row=0,column=0,columnspan=3) #self.mouse_button = Button(self.controlwin, text="Move mouse ",font=self.mediumfont, command=self.toggle_move_mouse) #self.mouse_button.grid(row=1,column=0) #if defines.USE_MOUSE: # self.mouse_button.configure(background="#00ff00") #else: # self.mouse_button.configure(background="#ff0000") mouse_speed_label = Label(self.controlwin,text="Mouse speed:",font=tkFont.nametofont("TkTextFont")) mouse_speed_label.grid(row=2,column=0) self.mouse_speed_scale = Scale(self.controlwin, from_=1, to=9,font=tkFont.nametofont("TkTextFont"), orient=HORIZONTAL,command=self.save_mouse_speed) self.mouse_speed_scale.grid(row=2,column=1) self.mouse_speed_scale.set(defines.MOUSE_SPEED) start_hour_label = Label(self.controlwin,text="Hour to start:",font=tkFont.nametofont("TkTextFont")) start_hour_label.grid(row=3,column=0) self.start_hour_scale = Scale(self.controlwin, from_=0, to=24,font=tkFont.nametofont("TkTextFont"), orient=HORIZONTAL,command=self.save_start_hour) self.start_hour_scale.grid(row=3,column=1) self.start_hour_scale.set(defines.START_HOUR) stop_hour_label = Label(self.controlwin,text="Hour to stop:",font=tkFont.nametofont("TkTextFont")) stop_hour_label.grid(row=4,column=0) self.stop_hour_scale = Scale(self.controlwin, from_=0, to=24,font=tkFont.nametofont("TkTextFont"), orient=HORIZONTAL,command=self.save_stop_hour) self.stop_hour_scale.grid(row=4,column=1) self.stop_hour_scale.set(defines.STOP_HOUR)
def zoom_in(self, event=None): """ Ctrl+= increases text size """ self.root.grid_propagate(False) font = tkFont.nametofont("CodeFont") size = font.actual()["size"] + 2 font.configure(size=size) # Increase size of line number self.linenumbers.config(width=self.linenumbers.winfo_width() + 3) return 'break'
def zoom_out(self, event=None): """ Ctrl+- decreases text size (minimum of 8) """ self.root.grid_propagate(False) font = tkFont.nametofont("CodeFont") size = font.actual()["size"] - 2 if size >= 8: font.configure(size=size) self.linenumbers.config(width=self.linenumbers.winfo_width() - 3) return 'break'
def create_res_window(self, results, table_name): """Creates a window to navigate and select item results of query. As side effect, uses set_selection function to resolve selection events. :param results: the results to display :param table_name: the name of the table being queried :return: None """ self.results = results def to_string(item): """Returns an appropriate string reps for results display. :param item: item to represent :return: formatted string """ the_string = '' for i in [1, 2, 3, 4, 8, 6]: if i == 6: the_string += "$" + "%.2f" % item[i] + ' ' elif i == 2: if table_name == 'Tie': the_string += str(item[i]) + '"' + ' ' else: the_string += str(item[i]) + ' ' elif i == 8: the_string += item[i] + " (" + item[10] + ", " + item[11] + ") " else: the_string += item[i] + ' ' return the_string # setup toplevel display self.scroll_window = Toplevel(self.frame) self.scroll_window.geometry("%dx%d%+d%+d" % (500, 200, self.frame.winfo_rootx()+10, self.frame.winfo_rooty())) inner_window = Frame(self.scroll_window) inner_window.pack(fill=BOTH) # setup horizontal and vertical scrollbars scrollbar = Scrollbar(inner_window, orient=VERTICAL) xscrollbar = Scrollbar(inner_window, orient=HORIZONTAL) self.select_list = Listbox(inner_window, yscrollcommand=scrollbar.set, xscrollcommand=xscrollbar.set, font=tkFont.nametofont('TkFixedFont')) scrollbar.config( command = self.select_list.yview) scrollbar.pack(side=RIGHT, fill=Y) xscrollbar.config( command = self.select_list.xview) xscrollbar.pack(side=BOTTOM, fill=X) # insert string reps of result items for item in results: self.select_list.insert(END, to_string(item)) self.select_list.pack(side=LEFT, fill=BOTH, expand=1) #currently destroy window... need to return/set selection Button(self.scroll_window, text="Select", command=self.set_selection).pack(side=LEFT, expand=1) Button(self.scroll_window, text="Cancel", command=lambda: self.set_selection(True)).pack(side=RIGHT, expand=1)
def main(): global root root = Tk.Tk() app = gui_dark(root) default_font = tkFont.nametofont("TkDefaultFont") default_font.configure(size=12) root.option_add("*Font", default_font) root.option_add("*Font", default_font) root.mainloop()
def configure_font(self): """ Sets up font for the editor """ if SYSTEM == MAC_OS: fontfamily = "Monaco" elif SYSTEM == WINDOWS: fontfamily = "Consolas" else: fontfamily = "Courier New" self.font_names = [] self.font = tkFont.Font(family=fontfamily, size=12, name="Font") self.font.configure(**tkFont.nametofont("Font").configure()) self.font_names.append("Font") self.font_bold = tkFont.Font(family=fontfamily, size=12, weight="bold", name="BoldFont") self.font_bold.configure(**tkFont.nametofont("BoldFont").configure()) self.font_names.append("BoldFont") self.font_italic = tkFont.Font(family=fontfamily, size=12, slant="italic", name="ItalicFont") self.font_italic.configure( **tkFont.nametofont("ItalicFont").configure()) self.font_names.append("ItalicFont") self.configure(font="Font") self.bracket_style = {'borderwidth': 2, 'relief': 'groove'} self.bracket_tag = "tag_open_brackets" self.tag_config(self.bracket_tag, **self.bracket_style) return
def set_font(root, size): """TODO: Docstring for set_font. :root: TODO :size: TODO :returns: TODO """ default_font = tkFont.nametofont('TkDefaultFont') default_font.configure(size=size) root.option_add('*Font', default_font)
def createLabel(self, text, row): paddingLeft = WINDOW_BORDER paddingTop = WINDOW_BORDER if (row == 0) else 0 labelFont = tkFont.nametofont("TkDefaultFont") text = text + ":" label = Tkinter.Label(self, anchor="e", fg="black", text=text, width=WINDOW_LABEL_WIDTH, font=labelFont) label.grid( column=0, row=row, sticky="NE", padx=(paddingLeft, WINDOW_SPACING), pady=(paddingTop, WINDOW_SPACING) )
def ChangeFontSize(self, amount): """ Updates the font sizes of the text based on `amount` which can be positive or negative """ self.root.grid_propagate(False) for font in self.text.font_names: font = tkFont.nametofont(font) size = max(8, font.actual()["size"] + amount) font.configure(size=size) self.text.char_w = self.text.font.measure(" ") self.text.char_h = self.text.font.metrics("linespace") return
def setStyles(): style = ttk.Style() #style.configure(".", font=('Helvetica', 8), foreground="white") style.configure(TREEVIEW_DIALOG_STYLE, foreground='blue') h = TREEVIEW_DIALOG_STYLE + '.Heading' style.configure(h, font=('Helvetica', 12)) #set buttons style style = ttk.Style() default_font = tkFont.nametofont("TkDefaultFont") style.configure(BUTTON_STYLE, font=default_font)
def main(): root = Tk() myFont = tkFont.nametofont("TkDefaultFont") myFont.configure(size=11) run = Run(root) #root.attributes('-fullscreen', True) root.geometry('1280x729+0+0') root.option_add('*Font', myFont) root.mainloop() root.quit() root.destroy()
def __init__(self, *args, **kwargs): tk.Label.__init__(self, *args, **kwargs) # clone the font, so we can dynamically change # it to fit the label width font = self.cget("font") base_font = tkFont.nametofont(self.cget("font")) self.font = tkFont.Font() self.font.configure(**base_font.configure()) self.configure(font=self.font) self.bind("<Configure>", self._on_configure)
def createSpace(self, row): paddingLeft = WINDOW_BORDER paddingTop = WINDOW_BORDER if (row == 0) else 0 labelFont = tkFont.nametofont("TkDefaultFont") labelFont = labelFont.copy() labelFont.config(weight='bold') text = "" label = Tkinter.Label(self, anchor="e", fg="black", text=text, width=WINDOW_LABEL_WIDTH, font=labelFont) label.grid(column=0, row=row, sticky='NE', padx=(paddingLeft, WINDOW_SPACING), pady=(paddingTop, WINDOW_SPACING))
def list_ui(self, td_file, root_frame=None, include_func=None): ''' add lists for each priority to root_frame include_func is called on each item to determine if it should be shown ''' if include_func is None: include_func = self.includeAll if root_frame is None: root_frame = self.frame # add panes # container for 2 sub-containers (high and low priority) lbox_panes = tk.PanedWindow(root_frame, orient=tk.VERTICAL, height=800) lbox_panes.pack(fill=tk.BOTH, expand=1) high_pri_pane = tk.PanedWindow(lbox_panes, orient=tk.HORIZONTAL, sashwidth=10) high_pri_pane.pack(fill=tk.BOTH, expand=1) lbox_panes.add(high_pri_pane) low_pri_pane = tk.PanedWindow(lbox_panes, orient=tk.HORIZONTAL) low_pri_pane.pack(fill=tk.BOTH, expand=1) lbox_panes.add(low_pri_pane) pri_lists = {} default_font = tkFont.nametofont("TkDefaultFont") default_family = default_font['family'] aLabelFont = tkFont.Font(size="16", family=default_family ) pri_lists["A"] = tk.LabelFrame( high_pri_pane, text=self.pri_map["A"], font=aLabelFont) pri_lists["A"].pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.add_listbox( pri_lists["A"], "A", tkFont.Font(size="13", family=default_family, weight="bold"), include_func, td_file) high_pri_pane.add(pri_lists["A"], stretch="always") # Pri <None> listbox pri_lists["B"] = tk.LabelFrame( high_pri_pane, text=self.pri_map["B"], font=aLabelFont) pri_lists["B"].pack(fill=tk.BOTH, expand=1) self.add_listbox( pri_lists["B"], "B", tkFont.Font(size="12",family=default_family), include_func, td_file) high_pri_pane.add(pri_lists["B"], stretch="always") for pri in ["C", "D", None]: # for pri in self.active_td_file().get_priorities(): pri_lists[pri] = tk.LabelFrame(low_pri_pane, text=self.pri_map[pri]) pri_lists[pri].pack(fill=tk.BOTH, expand=1) self.add_listbox( pri_lists[pri], pri, tkFont.Font(size="10", family=default_family), include_func, td_file) low_pri_pane.add(pri_lists[pri], stretch="always")
def __init__(self): fonts = dict() defaultfont = tkFont.nametofont('TkDefaultFont') defaultfontspecs = defaultfont.actual() fonts['header1'] = dict(size=16) fonts['header2'] = dict(size=13, weight='bold') fonts['header3'] = dict(size=10, weight='bold') fonts['hyperlink_active'] = dict(defaultfontspecs, underline=True) # Yes, this is ok, later keys will override keys in the first dict. fonts['hyperlink_inactive'] = dict(defaultfontspecs, underline=False)#, color='blue') # color cannot be used as a init keyword. fonts['emphasis'] = dict(defaultfontspecs, slant='italic')#, color='blue') # color cannot be used as a init keyword. self.CustomFonts = dict() for name, specs in fonts.items(): self.CustomFonts[name] = tkFont.Font(name=name, **specs)
def __init__(self, root): self.root = root self.root.iconbitmap('favicon.ico') self.root.title('WinDJHelper') default_font = tkFont.nametofont("TkDefaultFont") default_font.configure(size=14) self.root.option_add("*Font", default_font) self.root.bind('<<keypressed>>', self.ButtonPress) # message self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() result = [] mods = self.player.audio_output_device_enum() if mods: mod = mods while mod: mod = mod.contents result.append((mod.description, mod.device)) mod = mod.next vlc.libvlc_audio_output_device_list_release(mods) devices = '' for index, value in enumerate(result): devices += '%s: %s' % (value[0], value[1]) if index != len(result)-1: devices += '\n' self.title = Label(root, text='DEVICES:') self.title.grid(row=0, padx=5, pady=(5,0)) self.label1 = Text(self.root, height=len(result)) self.label1.insert(1.0, devices) self.label1.configure(state="disabled") self.label1.configure(bg=root.cget('bg'), relief=FLAT) self.label1.grid(row=1, padx=5, pady=5) self.scancodeval = StringVar() self.scancodeval.set('KEY CODES:\n') self.label2 = Label(self.root, textvariable=self.scancodeval) self.label2.grid(row=2, padx=5, pady=5) # buttons ok = Button(self.root, width=8, text='OK', command=self.dismiss) ok.grid(row=3, padx=5, pady=(0,5)) ok.focus_set()
def append( self, s_text = "", u_baton = None ): ##! |Treeview| widget interprets |\| symbol as escape. if sys.platform != 'win32': s_text = s_text.replace( "\\", "\\\\" ) ##! |Treeview| will not display text with spaces without quotes. s_text = "{0}".format( s_text ) sId = self._context_o.insert( '', 'end', iid = None, text = s_text ) if self._firstId_s is None: self._firstId_s = sId self._items_m[ sId ] = u_baton nWidth = tkFont.nametofont( 'TkDefaultFont' ).measure( s_text ) if nWidth > self._maxWidth_n: self._maxWidth_n = nWidth return sId
def onResize(self, event): SW = self.winfo_width() self.fontscale = int(SW / 80) if self.fontscale < 8: self.fontscale = 8 for fontname in ["TkDefaultFont", "TkTextFont", "TkMenuFont", "TkCaptionFont", "TkFixedFont" ]: default_font = tkFont.nametofont(fontname) default_font.configure(size = self.fontscale) if 'PyGrbl_ControlPanel' in self.apps: self.ControlPanel.JogButtonFont.configure(size = int(self.fontscale * 2.5)) self.update_idletasks()
def __init__(self, master, tClient): self.queue = tClient.queue self.parent = master self.tClient = tClient self._textFont = tkFont.Font(name="TextFont") self._textFont.configure(**tkFont.nametofont("TkDefaultFont").configure()) self._sbFont = tkFont.Font(name="StatusBarFont") self._sbFont.configure(**tkFont.nametofont("TkDefaultFont").configure()) self.statusBar = tk.Frame(master, borderwidth=0) container = tk.Frame(master, borderwidth=1, relief="sunken", width=600, height=600) container.grid_propagate(False) self.statusBar.pack(side="bottom", fill="x") container.pack(side="top", fill="both", expand=True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.lText = tk.StringVar() text = tk.Label(container, font="TextFont", textvariable=self.lText, justify='left') text.grid(row=0, column=0, sticky="nsew") self.statBarText = tk.StringVar() self.lStatus = tk.Label(self.statusBar, font='StatusBarFont', textvariable=self.statBarText ) self.lStatus.pack(side='left') container.bind("<Configure>", self.resize) master.protocol("WM_DELETE_WINDOW", tClient.endApplication) self.availableTimers=[10,60,120,180,240,300,360,600] self.selectedTimer = 5#5 min is default self.state = self.TIMER_STOPPED self.timerTickCount=self.availableTimers[self.selectedTimer] self.hideRacetimer = False self.showHelp()
def ScaleFont(self, tLen): """ Scale timer text as big it can be. todo: Check is there better way than hardcoded scaling factors ? """ if tLen == 0: return width= self.parent.winfo_width() height = self.parent.winfo_height() font = tkFont.nametofont("TextFont") size = int(height * 0.7) size2 = int((width / tLen) * 1.3) if size2 < size: size = size2 font.configure(size=size)
def resolutions(self): self.resolutionwin = Toplevel(self) self.resolutionwin.resizable(0,0) custom_title = Label(self.resolutionwin,text="Resolutions:",font=tkFont.nametofont("TkTextFont")) custom_title.grid(row=0,column=0) #self.resvar = IntVar() #self.resvar.set(defines.GAME_SCREEN_RES) #print self.resvar.get() ##for i in xrange(len(defines.game_screen_res_list)): #i=0 #Radiobutton(self.resvar, text='Test',font=tkFont.nametofont("TkTextFont"), variable=self.resvar, value=0, command=self.config_resolution).grid(row=i+1,column=0,sticky=W) self.resvar = IntVar() self.resvar.set(defines.GAME_SCREEN_RES) for i in xrange(len(defines.game_screen_res_list)): Radiobutton(self.resolutionwin, text=str(defines.game_screen_res_list[i]),font=tkFont.nametofont("TkTextFont"), variable=self.resvar, value=i, command=self.config_resolution).grid(row=i+1,column=0,sticky=W)
def initUI(self): self.parent.title('Hypergeometric Distribution Simulator') labelfont = tkFont.nametofont('TkDefaultFont') labelfont.config(size=12) #frame for data entry (grid manager) self.fields = Frame(self) self.fields.pack(side=LEFT, fill=Y) #labels for data entry self.sampleLabel = Label(self.fields, text='Sample Size:') self.sampleLabel.grid(row=0, column=0, sticky=W, padx=5, pady=5) self.populationLabel = Label(self.fields, text='Population Size:') self.populationLabel.grid(row=1, column=0, sticky=W, padx=5, pady=5) self.numSuccessesLabel = Label(self.fields, text='Number of Successes:') self.numSuccessesLabel.grid(row=2, column=0, sticky=W, padx=5, pady=5) self.numTrialsLabel = Label(self.fields, text='Number of Trials:') self.numTrialsLabel.grid(row=3, column=0, sticky=W, padx=5, pady=5) #input boxes and submit button for data entry self.sampleEntry = Entry(self.fields) self.sampleEntry.grid(row=0, column=1, padx=5, pady=5) self.populationEntry = Entry(self.fields) self.populationEntry.grid(row=1, column=1, padx=5, pady=5) self.numSuccessesEntry = Entry(self.fields) self.numSuccessesEntry.grid(row=2, column=1, padx=5, pady=5) self.numTrialsEntry = Entry(self.fields) self.numTrialsEntry.grid(row=3, column=1, padx=5, pady=5) self.runTrialsButton = Button(self.fields, text='Run Experiment', command=self.runExperiment) self.runTrialsButton.grid(row=4, column=1, sticky=E, padx=5, pady=5) #canvas self.canvas = Canvas(self, background='white') self.canvas.pack(side=RIGHT, fill=BOTH, expand=1) #main window centering self.pack(fill=BOTH, expand=1) self.centerWindow()
def __init__(self,parent,**kw): self.mFont = kw.pop("mFont",tkFont.nametofont("TkDefaultFont")) self.callback = kw.pop("callback",None) self.add_text = kw.pop("text","Add") underline = kw.pop("button_underline",-1) self.list = [] tk.Frame.__init__(self,parent,kw) self.scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL) self.list_body = tk.Listbox(self, background="#F0F8FF",font=self.mFont, width=10,yscrollcommand=self.scrollbar.set) self.list_body.bind("<MouseWheel>",lambda event : self.list_body.yview("scroll",-event.delta/120,"units")) self.scrollbar.config(command=self.list_body.yview) self.addbutton = ttk.Button(self,text=self.add_text,underline=underline,command=lambda widget=self,parent=parent : self.callback(widget,parent)) self.addbutton.grid(row=1,columnspan=2,stick="WE") self.scrollbar.grid(row=0,column=1,sticky="SN") self.list_body.grid(row=0,column=0,sticky="NSWE") self.grid_rowconfigure(0,weight=1)