def test_askfont(self): def test(event): event.widget.ok() fontprops = event.widget.get_res() self.assertEqual(fontprops['size'], 20) self.assertEqual(fontprops['slant'], 'italic') self.assertEqual(fontprops['weight'], 'bold') self.assertTrue(fontprops['underline']) self.assertTrue(fontprops['overstrike']) def events(): self.window.update() c = list(self.window.children.values())[0] c.bind('<Visibility>', test) self.window.update() c.withdraw() self.window.update() c.deiconify() self.window.after(100, events) askfont(master=self.window, family='TkDefaultFont', size=20, slant='italic', weight='bold', underline=True, overstrike=True)
def change_font(self, event=None): status.config(text="Changing Font") font = askfont( window, title="Select Font", family=self.cur_font_fam, size=self.cur_font_size, slant=self.cur_font_slant, weight=self.cur_font_weight, underline=0 if self.cur_font_under == "normal" else 1, overstrike=0 if self.cur_font_overstrike == "normal" else 1) if font: self.cur_font_fam = font["family"] font['family'] = font['family'].replace(' ', '\ ') self.cur_font_size = font["size"] self.cur_font_slant = font["slant"] self.cur_font_weight = font["weight"] print(self.cur_font_overstrike) font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font['underline']: self.cur_font_under = 'underline' font_str += ' underline' else: self.cur_font_under = 'normal' if font['overstrike']: self.cur_font_overstrike = 'overstrike' font_str += ' normal' else: self.cur_font_overstrike = 'overstrike' self.configure(font=font_str) status.config(text="Font is changed to " + font_str) sleep(.300) self.showrowcol()
def fontcallback(self, font_sel, btn): """ Font picker. Seleziona il carattere da utilizzare all'interno dell'applicazione. Parametri ---------- :param Label font_sel : Etichetta font selezionato. :param Button btn : Pulsante SALVA Ritorna ------- Niente """ # chiedi il font all'utente font = askfont(self.__root, title="Selettore carattere") # la variabile font è "" se l'utente ha annullato if font: # spaces in the family name need to be escaped font['family'] = font['family'].replace(' ', '\ ') font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font['underline']: font_str += ' underline' if font['overstrike']: font_str += ' overstrike' font_sel.configure(font=font_str, text="Carattere selezionato:\n {}".format( font_str.replace('\\', ' '))) btn.configure(command=lambda: self.__style.set_font(font_str))
def font_chooser(): font = askfont(window) if font: textFont = tkFont.Font(family=font['family'], size=font['size'], weight=font['weight'], slant=font['slant']) txt_edit.configure(font=textFont)
def set_font(self, *args): font = askfont(self.master) if font: font['family'] = font['family'].replace(' ', '\ ') font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font['underline']: font_str += ' underline' if font['overstrike']: font_str += ' overstrike' self.textarea['font'] = font_str
def font_style(self): font = askfont(self.root) if font: font['family'] = font['family'].replace(' ', '\ ') font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font['underline']: font_str += ' underline' if font['overstrike']: font_str += ' overstrike' self.text["font"] = font_str
def font_box(): font = askfont(root) if font: font["family"] = font["family"].replace(" ", "\ ") font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font["underline"]: font_str += " underline" if font["overstrike"]: font_str += " overstrike" print(font_str) text_area.configure(font=font_str)
def callback(): # open the font chooser and get the font selected by the user font = askfont(root) # font is "" if the user has cancelled if font: # spaces in the family name need to be escaped font['family'] = font['family'].replace(' ', '\ ') font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font['underline']: font_str += ' underline' if font['overstrike']: font_str += ' overstrike' label.configure(font=font_str, text='Chosen font: ' + font_str.replace('\ ', ' '))
def chfont(self): font = askfont(self.master) if font: font['family'] = font['family'].replace(' ', '\ ') font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font['underline']: font_str += ' underline' if font['overstrike']: font_str += ' overstrike' self.ta['font'] = font_str self.ta['height'] = self.ta['height'] - font['size'] self.ta['width'] = self.ta['width'] - font['size']
def select_font(self): font= askfont() # font is "" if the user has cancelled if font: # spaces in the family name need to be escaped font['family'] = font['family'].replace(' ', '\ ') font_str = "%(family)s %(size)i %(weight)s %(slant)s" % font if font['underline']: font_str += ' underline' if font['overstrike']: font_str += ' overstrike' self.font_style = font_str self.textarea.configure(font=self.font_style)
def change_font(self): font = tkfontchooser.askfont(self.main.master) if font: tkfont = tk.font.Font(self.main.master, family=font['family'], size=font['size'], weight=font['weight'], slant=font['slant'], underline=font['underline'], overstrike=font['overstrike']) self.main.textbox.config(font=tkfont) for key, value in font.items(): self.config['Font'][str(key)] = str(value)
def font(): f=fc.askfont() fnt=f["family"] fnt1=fnt.replace(" ","") siz=f["size"] font1=str(fnt1)+" "+str(siz) if f["underline"]==1: font1=font1+" underline" if f["overstrike"]==1: font1=font1+" overstrike" if f["weight"]=="bold": font1=font1+" bold" if f["slant"]=="italic": font1=font1+" italic" tp.configure(font=font1)
def change_font(self, event = None): font_dict = tkfontchooser.askfont(**self.font_dict) if font_dict != '': self.font_dict = font_dict font_dict = list(font_dict.values()) font = Font(family = font_dict[0], size = font_dict[1], weight = font_dict[2], slant = font_dict[3], underline = font_dict[4], overstrike = font_dict[5]) self.font = font self.text.config(font = self.font) with open(os.path.join(self.home, '.SB_Text_Editor/settings.txt'), 'w') as settings: tmp = ';'.join(map(lambda item: str(item), list(self.font_dict.values()))) tmp += '\n'+self.bg+';'+self.fg settings.write(tmp)
def set_font_settings(self): new_font = askfont(self, _get_klayout_lang(random.choice(_KLAYOUTS))) if new_font: self.new_settings["font_settings"].set(fontactual2str(new_font))
def choose_font(): global font font = askfont(master)
#!/usr/bin/python3 from tkfontchooser import askfont if __name__ == "__main__": dialog = askfont() print('You selected: {0}\n'.format(dialog))
def get_font(self): font = tkfontchooser.askfont() if font != '': self.font = list(font.values())
def askingfont(): global font font = askfont(fenetre) print(font)
def adj_font(lyric_display, window, window_properties): temp = tkfontchooser.askfont(window) for font_attr in temp: window_properties.font[font_attr] = temp[font_attr] lyric_display.config(font=window_properties.font)
def change_font_style(): font_ = askfont(root) if type(font_) == dict: font_ = list(font_.values()) font_ = Font(family = font_[0], size = font_[1], weight = font_[2], slant = font_[3], underline = font_[4], overstrike = font_[5]) text_box.config(font = font_)