{"id":24568,"date":"2022-12-04T00:58:43","date_gmt":"2022-12-03T19:28:43","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/"},"modified":"2022-12-04T00:58:43","modified_gmt":"2022-12-03T19:28:43","slug":"solved-how-to-bind-classes-to-another-widget","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/","title":{"rendered":"[Solved] How to bind classes to another widget"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-50720491\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"50720491\" data-parentid=\"50718834\" data-score=\"1\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Everything you need to make this work is located in the <code>callback()<\/code> and <code>askfont()<\/code> methods in the font code. You need to take elements from <code>callback()<\/code> and <code>askfont()<\/code> and incorporate them into your code.<\/p>\n<p>You will also need to import the font code. Lets say the Font code is in the same directory as our <code>main.py<\/code> and we call this file <code>font.py<\/code>.<\/p>\n<p>UPDATE: To address the latest addition to your question all you need to do is <code>text.pack(expand=True, fill=\"x\")<\/code>. This will tell the text widget to fill the frame or window it is in.<\/p>\n<p>Your code should look something like this:<\/p>\n<pre><code>from tkinter import *\nimport font as pyfont\nimport tkinter.font as xFont\n\ndef edit_font():\n    # this line waits for askfont to return the new chosen font.\n    font = pyfont.askfont(root, title=\"Choose a font\")\n\n    # this if statement will convert the dictionary that is returned from\n    # the askfont function into something we can use to configure the texbox.\n    if font:\n            # spaces in the family name need to be escaped\n            font['family'] = font['family'].replace(' ', '\\ ')\n            font_str = \"%(family)s %(size)i %(weight)s %(slant)s\" % font\n            if font['underline']:\n                font_str += ' underline'\n            if font['overstrike']:\n                font_str += ' overstrike'\n            text.configure(font=font_str)\n\nroot=Tk()\nroot.geometry(\"600x400\")\n\ntext=Text(root, font=xFont.Font(family=\"Helvetica\", size=10))\ntext.pack(expand=True, fill=\"x\")\n\nking=Menu(root)\nroot.config(menu=king)\n\nview= Menu(king, tearoff=0)\nview2=Menu(view, tearoff=0)\nview2.add_command(label=\"Font\",command=edit_font)\n\nview.add_cascade(label=\"Text\", menu=view2)\nking.add_cascade(label=\"View\", menu=view)\n\nroot.mainloop()\n<\/code><\/pre>\n<p>UPDATE:<\/p>\n<p>Because in the comments you stated the code is all in the same file that changes things. I recommend against this and you should separate your code to their own files and import what you need. <\/p>\n<p>That said to address the issues at hand please see the below code.<\/p>\n<p>At the bottom is your GUI code. Let me know if you have any questions. <\/p>\n<pre><code>try:\n    import tkinter as tk\n    from tkinter import Toplevel, Listbox, StringVar, BooleanVar, TclError\n    from tkinter.ttk import Checkbutton, Frame, Label, Button, Scrollbar, Style, Entry\n    from tkinter.font import families, Font\nexcept ImportError:\n    import Tkinter as tk\n    from Tkinter import Toplevel, Listbox, StringVar, BooleanVar\n    from ttk import Checkbutton, Frame, Label, Button, Scrollbar, Style, Entry\n    from tkFont import families, Font\n\nfrom locale import getdefaultlocale\n\n__version__ = \"2.0.2\"\n\n# --- translation\nEN = {\"Cancel\": \"Cancel\", \"Bold\": \"Bold\", \"Italic\": \"Italic\",\n      \"Underline\": \"Underline\", \"Overstrike\": \"Strikethrough\"}\nFR = {\"Cancel\": \"Annuler\", \"Bold\": \"Gras\", \"Italic\": \"Italique\",\n      \"Underline\": \"Soulign\u00e9\", \"Overstrike\": \"Barr\u00e9\"}\nLANGUAGES = {\"fr\": FR, \"en\": EN}\n\nif getdefaultlocale()[0][:2] == \"fr\":\n    TR = LANGUAGES[\"fr\"]\nelse:\n    TR = LANGUAGES[\"en\"]\n\n\n# --- FontChooser class\nclass FontChooser(Toplevel):\n    \"\"\".Font chooser dialog.\"\"\"\n\n    def __init__(self, master, font_dict={}, text=\"Abcd\", title=\"Font Chooser\",\n                 **kwargs):\n        \"\"\"\n        Create a new FontChooser instance.\n        Arguments:\n            master: master window\n            font_dict: dictionnary, like the one returned by the .actual\n                       method of a Font object:\n                        {'family': 'DejaVu Sans',\n                         'overstrike': False,\n                         'size': 12,\n                         'slant': 'italic' or 'roman',\n                         'underline': False,\n                         'weight': 'bold' or 'normal'}\n            text: text to be displayed in the preview label\n            title: window title\n            **kwargs: additional keyword arguments to be passed to\n                      Toplevel.__init__\n        \"\"\"\n        Toplevel.__init__(self, master, **kwargs)\n        self.title(title)\n        self.resizable(False, False)\n        self.protocol(\"WM_DELETE_WINDOW\", self.quit)\n        self._validate_family = self.register(self.validate_font_family)\n        self._validate_size = self.register(self.validate_font_size)\n\n        # --- variable storing the chosen font\n        self.res = \"\"\n\n        style = Style(self)\n        style.configure(\"prev.TLabel\", background=\"white\")\n        bg = style.lookup(\"TLabel\", \"background\")\n        self.configure(bg=bg)\n\n        # --- family list\n        self.fonts = list(set(families()))\n        self.fonts.append(\"TkDefaultFont\")\n        self.fonts.sort()\n        for i in range(len(self.fonts)):\n            self.fonts[i] = self.fonts[i].replace(\" \", \"\\ \")\n        max_length = int(2.5 * max([len(font) for font in self.fonts])) \/\/ 3\n        self.sizes = [\"%i\" % i for i in (list(range(6, 17)) + list(range(18, 32, 2)))]\n        # --- font default\n        font_dict[\"weight\"] = font_dict.get(\"weight\", \"normal\")\n        font_dict[\"slant\"] = font_dict.get(\"slant\", \"roman\")\n        font_dict[\"underline\"] = font_dict.get(\"underline\", False)\n        font_dict[\"overstrike\"] = font_dict.get(\"overstrike\", False)\n        font_dict[\"family\"] = font_dict.get(\"family\",\n                                            self.fonts[0].replace('\\ ', ' '))\n        font_dict[\"size\"] = font_dict.get(\"size\", 10)\n\n        # --- creation of the widgets\n        # ------ style parameters (bold, italic ...)\n        options_frame = Frame(self, relief=\"groove\", borderwidth=2)\n        self.font_family = StringVar(self, \" \".join(self.fonts))\n        self.font_size = StringVar(self, \" \".join(self.sizes))\n        self.var_bold = BooleanVar(self, font_dict[\"weight\"] == \"bold\")\n        b_bold = Checkbutton(options_frame, text=TR[\"Bold\"],\n                             command=self.toggle_bold,\n                             variable=self.var_bold)\n        b_bold.grid(row=0, sticky=\"w\", padx=4, pady=(4, 2))\n        self.var_italic = BooleanVar(self, font_dict[\"slant\"] == \"italic\")\n        b_italic = Checkbutton(options_frame, text=TR[\"Italic\"],\n                               command=self.toggle_italic,\n                               variable=self.var_italic)\n        b_italic.grid(row=1, sticky=\"w\", padx=4, pady=2)\n        self.var_underline = BooleanVar(self, font_dict[\"underline\"])\n        b_underline = Checkbutton(options_frame, text=TR[\"Underline\"],\n                                  command=self.toggle_underline,\n                                  variable=self.var_underline)\n        b_underline.grid(row=2, sticky=\"w\", padx=4, pady=2)\n        self.var_overstrike = BooleanVar(self, font_dict[\"overstrike\"])\n        b_overstrike = Checkbutton(options_frame, text=TR[\"Overstrike\"],\n                                   variable=self.var_overstrike,\n                                   command=self.toggle_overstrike)\n        b_overstrike.grid(row=3, sticky=\"w\", padx=4, pady=(2, 4))\n        # ------ Size and family\n        self.var_size = StringVar(self)\n        self.entry_family = Entry(self, width=max_length, validate=\"key\",\n                                  validatecommand=(self._validate_family, \"%d\", \"%S\",\n                                                   \"%i\", \"%s\", \"%V\"))\n        self.entry_size = Entry(self, width=4, validate=\"key\",\n                                textvariable=self.var_size,\n                                validatecommand=(self._validate_size, \"%d\", \"%P\", \"%V\"))\n        self.list_family = Listbox(self, selectmode=\"browse\",\n                                   listvariable=self.font_family, highlightthickness=0, exportselection=False, width=max_length)\n        self.list_size = Listbox(self, selectmode=\"browse\",\n                                 listvariable=self.font_size, highlightthickness=0, exportselection=False, width=4)\n        scroll_family = Scrollbar(self, orient=\"vertical\", command=self.list_family.yview)\n        scroll_size = Scrollbar(self, orient=\"vertical\", command=self.list_size.yview)\n        self.preview_font = Font(self, **font_dict)\n        if len(text) &gt; 30:\n            text = text[:30]\n        self.preview = Label(self, relief=\"groove\", style=\"prev.TLabel\", text=text, font=self.preview_font, anchor=\"center\")\n\n        self.list_family.configure(yscrollcommand=scroll_family.set)\n        self.list_size.configure(yscrollcommand=scroll_size.set)\n        self.entry_family.insert(0, font_dict[\"family\"])\n        self.entry_family.selection_clear()\n        self.entry_family.icursor(\"end\")\n        self.entry_size.insert(0, font_dict[\"size\"])\n        try:\n            i = self.fonts.index(self.entry_family.get().replace(\" \", \"\\ \"))\n        except ValueError:\n            i = 0\n        self.list_family.selection_clear(0, \"end\")\n        self.list_family.selection_set(i)\n        self.list_family.see(i)\n        try:\n            i = self.sizes.index(self.entry_size.get())\n            self.list_size.selection_clear(0, \"end\")\n            self.list_size.selection_set(i)\n            self.list_size.see(i)\n        except ValueError:\n            pass\n\n        self.entry_family.grid(row=0, column=0, sticky=\"ew\", pady=(10, 1), padx=(10, 0))\n        self.entry_size.grid(row=0, column=2, sticky=\"ew\", pady=(10, 1), padx=(10, 0))\n        self.list_family.grid(row=1, column=0, sticky=\"nsew\", pady=(1, 10), padx=(10, 0))\n        self.list_size.grid(row=1, column=2, sticky=\"nsew\", pady=(1, 10), padx=(10, 0))\n        scroll_family.grid(row=1, column=1, sticky='ns', pady=(1, 10))\n        scroll_size.grid(row=1, column=3, sticky='ns', pady=(1, 10))\n        options_frame.grid(row=0, column=4, rowspan=2, padx=10, pady=10, ipadx=10)\n\n        self.preview.grid(row=2, column=0, columnspan=5, sticky=\"eswn\", padx=10, pady=(0, 10), ipadx=4, ipady=4)\n        button_frame = Frame(self)\n        button_frame.grid(row=3, column=0, columnspan=5, pady=(0, 10), padx=10)\n        Button(button_frame, text=\"Ok\", command=self.ok).grid(row=0, column=0, padx=4, sticky='ew')\n        Button(button_frame, text=TR[\"Cancel\"], command=self.quit).grid(row=0, column=1, padx=4, sticky='ew')\n        self.list_family.bind('&lt;&lt;ListboxSelect&gt;&gt;', self.update_entry_family)\n        self.list_size.bind('&lt;&lt;ListboxSelect&gt;&gt;', self.update_entry_size, add=True)\n        self.list_family.bind(\"&lt;KeyPress&gt;\", self.keypress)\n        self.entry_family.bind(\"&lt;Return&gt;\", self.change_font_family)\n        self.entry_family.bind(\"&lt;Tab&gt;\", self.tab)\n        self.entry_size.bind(\"&lt;Return&gt;\", self.change_font_size)\n        self.entry_family.bind(\"&lt;Down&gt;\", self.down_family)\n        self.entry_size.bind(\"&lt;Down&gt;\", self.down_size)\n        self.entry_family.bind(\"&lt;Up&gt;\", self.up_family)\n        self.entry_size.bind(\"&lt;Up&gt;\", self.up_size)\n        self.bind_class(\"TEntry\", \"&lt;Control-a&gt;\", self.select_all)\n\n        self.wait_visibility(self)\n        self.grab_set()\n        self.entry_family.focus_set()\n        self.lift()\n\n    def select_all(self, event):\n        event.widget.selection_range(0, \"end\")\n\n    def keypress(self, event):\n        key = event.char.lower()\n        l = [i for i in self.fonts if i[0].lower() == key]\n        if l:\n            i = self.fonts.index(l[0])\n            self.list_family.selection_clear(0, \"end\")\n            self.list_family.selection_set(i)\n            self.list_family.see(i)\n            self.update_entry_family()\n\n    def up_family(self, event):\n        try:\n            i = self.list_family.curselection()[0]\n            self.list_family.selection_clear(0, \"end\")\n            if i &lt;= 0:\n                i = len(self.fonts)\n            self.list_family.see(i - 1)\n            self.list_family.select_set(i - 1)\n        except TclError:\n            self.list_family.selection_clear(0, \"end\")\n            i = len(self.fonts)\n            self.list_family.see(i - 1)\n            self.list_family.select_set(i - 1)\n        self.list_family.event_generate('&lt;&lt;ListboxSelect&gt;&gt;')\n\n    def up_size(self, event):\n        \"\"\"Navigate in the size listbox with up key.\"\"\"\n        try:\n            s = self.var_size.get()\n            if s in self.sizes:\n                i = self.sizes.index(s)\n            elif s:\n                sizes = list(self.sizes)\n                sizes.append(s)\n                sizes.sort(key=lambda x: int(x))\n                i = sizes.index(s)\n            else:\n                i = 0\n            self.list_size.selection_clear(0, \"end\")\n            if i &lt;= 0:\n                i = len(self.sizes)\n            self.list_size.see(i - 1)\n            self.list_size.select_set(i - 1)\n        except TclError:\n            i = len(self.sizes)\n            self.list_size.see(i - 1)\n            self.list_size.select_set(i - 1)\n        self.list_size.event_generate('&lt;&lt;ListboxSelect&gt;&gt;')\n\n    def down_family(self, event):\n        \"\"\"Navigate in the family listbox with down key.\"\"\"\n        try:\n            i = self.list_family.curselection()[0]\n            self.list_family.selection_clear(0, \"end\")\n            if i &gt;= len(self.fonts):\n                i = -1\n            self.list_family.see(i + 1)\n            self.list_family.select_set(i + 1)\n        except TclError:\n            self.list_family.selection_clear(0, \"end\")\n            self.list_family.see(0)\n            self.list_family.select_set(0)\n        self.list_family.event_generate('&lt;&lt;ListboxSelect&gt;&gt;')\n\n    def down_size(self, event):\n        \"\"\"Navigate in the size listbox with down key.\"\"\"\n        try:\n            s = self.var_size.get()\n            if s in self.sizes:\n                i = self.sizes.index(s)\n            elif s:\n                sizes = list(self.sizes)\n                sizes.append(s)\n                sizes.sort(key=lambda x: int(x))\n                i = sizes.index(s) - 1\n            else:\n                s = len(self.sizes) - 1\n            self.list_size.selection_clear(0, \"end\")\n            if i &lt; len(self.sizes) - 1:\n                self.list_size.selection_set(i + 1)\n                self.list_size.see(i + 1)\n            else:\n                self.list_size.see(0)\n                self.list_size.select_set(0)\n        except TclError:\n            self.list_size.selection_set(0)\n        self.list_size.event_generate('&lt;&lt;ListboxSelect&gt;&gt;')\n\n    def toggle_bold(self):\n        \"\"\"Update font preview weight.\"\"\"\n        b = self.var_bold.get()\n        self.preview_font.configure(weight=[\"normal\", \"bold\"][b])\n\n    def toggle_italic(self):\n        \"\"\"Update font preview slant.\"\"\"\n        b = self.var_italic.get()\n        self.preview_font.configure(slant=[\"roman\", \"italic\"][b])\n\n    def toggle_underline(self):\n        \"\"\"Update font preview underline.\"\"\"\n        b = self.var_underline.get()\n        self.preview_font.configure(underline=b)\n\n    def toggle_overstrike(self):\n        \"\"\"Update font preview overstrike.\"\"\"\n        b = self.var_overstrike.get()\n        self.preview_font.configure(overstrike=b)\n\n    def change_font_family(self, event=None):\n        \"\"\"Update font preview family.\"\"\"\n        family = self.entry_family.get()\n        if family.replace(\" \", \"\\ \") in self.fonts:\n            self.preview_font.configure(family=family)\n\n    def change_font_size(self, event=None):\n        \"\"\"Update font preview size.\"\"\"\n        size = int(self.var_size.get())\n        self.preview_font.configure(size=size)\n\n    def validate_font_size(self, d, ch, V):\n        \"\"\"Validation of the size entry content.\"\"\"\n        l = [i for i in self.sizes if i[:len(ch)] == ch]\n        i = None\n        if l:\n            i = self.sizes.index(l[0])\n        elif ch.isdigit():\n            sizes = list(self.sizes)\n            sizes.append(ch)\n            sizes.sort(key=lambda x: int(x))\n            i = min(sizes.index(ch), len(self.sizes))\n        if i is not None:\n            self.list_size.selection_clear(0, \"end\")\n            self.list_size.selection_set(i)\n            deb = self.list_size.nearest(0)\n            fin = self.list_size.nearest(self.list_size.winfo_height())\n            if V != \"forced\":\n                if i &lt; deb or i &gt; fin:\n                    self.list_size.see(i)\n                return True\n        if d == '1':\n            return ch.isdigit()\n        else:\n            return True\n\n    def tab(self, event):\n        \"\"\"Move at the end of selected text on tab press.\"\"\"\n        self.entry_family = event.widget\n        self.entry_family.selection_clear()\n        self.entry_family.icursor(\"end\")\n        return \"break\"\n\n    def validate_font_family(self, action, modif, pos, prev_txt, V):\n        \"\"\"Completion of the text in the entry with existing font names.\"\"\"\n        if self.entry_family.selection_present():\n            sel = self.entry_family.selection_get()\n            txt = prev_txt.replace(sel, '')\n        else:\n            txt = prev_txt\n        if action == \"0\":\n            txt = txt[:int(pos)] + txt[int(pos) + 1:]\n            return True\n        else:\n            txt = txt[:int(pos)] + modif + txt[int(pos):]\n            ch = txt.replace(\" \", \"\\ \")\n            l = [i for i in self.fonts if i[:len(ch)] == ch]\n            if l:\n                i = self.fonts.index(l[0])\n                self.list_family.selection_clear(0, \"end\")\n                self.list_family.selection_set(i)\n                deb = self.list_family.nearest(0)\n                fin = self.list_family.nearest(self.list_family.winfo_height())\n                index = self.entry_family.index(\"insert\")\n                self.entry_family.delete(0, \"end\")\n                self.entry_family.insert(0, l[0].replace(\"\\ \", \" \"))\n                self.entry_family.selection_range(index + 1, \"end\")\n                self.entry_family.icursor(index + 1)\n                if V != \"forced\":\n                    if i &lt; deb or i &gt; fin:\n                        self.list_family.see(i)\n                return True\n            else:\n                return False\n\n    def update_entry_family(self, event=None):\n        \"\"\"Update family entry when an item is selected in the family listbox.\"\"\"\n        #  family = self.list_family.get(\"@%i,%i\" % (event.x , event.y))\n        family = self.list_family.get(self.list_family.curselection()[0])\n        self.entry_family.delete(0, \"end\")\n        self.entry_family.insert(0, family)\n        self.entry_family.selection_clear()\n        self.entry_family.icursor(\"end\")\n        self.change_font_family()\n\n    def update_entry_size(self, event):\n        \"\"\"Update size entry when an item is selected in the size listbox.\"\"\"\n        #  size = self.list_size.get(\"@%i,%i\" % (event.x , event.y))\n        size = self.list_size.get(self.list_size.curselection()[0])\n        self.var_size.set(size)\n        self.change_font_size()\n\n    def ok(self):\n        \"\"\"Validate choice.\"\"\"\n        self.res = self.preview_font.actual()\n        self.quit()\n\n    def get_res(self):\n        \"\"\"Return chosen font.\"\"\"\n        return self.res\n\n    def quit(self):\n        self.destroy()\n\n\ndef askfont(master=None, text=\"Abcd\", title=\"Font Chooser\", **font_args):\n    chooser = FontChooser(master, font_args, text, title)\n    chooser.wait_window(chooser)\n    return chooser.get_res()\n\ndef edit_font():\n    font = askfont(root, title=\"Choose a font\")\n    if font:\n            font['family'] = font['family'].replace(' ', '\\ ')\n            font_str = \"%(family)s %(size)i %(weight)s %(slant)s\" % font\n            if font['underline']:\n                font_str += ' underline'\n            if font['overstrike']:\n                font_str += ' overstrike'\n            text.configure(font=font_str)\n\nroot=tk.Tk()\nroot.geometry(\"600x400\")\n# added weights so the widget resizes correctly with window\nroot.rowconfigure(0, weight=1)\nroot.columnconfigure(0, weight=1)\n\ntext=tk.Text(root, font=Font(family=\"Helvetica\", size=10))\ntext.grid(row=0, column=0, sticky=\"nsew\")\n\nking=tk.Menu(root)\nroot.config(menu=king)\n\nview=tk.Menu(king, tearoff=0)\nview2=tk.Menu(view, tearoff=0)\nview2.add_command(label=\"Font\",command=edit_font)\n\nview.add_cascade(label=\"Text\", menu=view2)\nking.add_cascade(label=\"View\", menu=view)\n\nroot.mainloop()\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">0<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved How to bind classes to another widget <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Everything you need to make this work is located in the callback() and askfont() methods in the font code. You need to take elements from callback() and askfont() and incorporate them into your code. You will also need to import the font code. Lets say the Font code is in the same directory as &#8230; <a title=\"[Solved] How to bind classes to another widget\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\" aria-label=\"More on [Solved] How to bind classes to another widget\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[349,482,768],"class_list":["post-24568","post","type-post","status-publish","format-standard","hentry","category-solved","tag-python","tag-python-3-x","tag-tkinter"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] How to bind classes to another widget - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] How to bind classes to another widget - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Everything you need to make this work is located in the callback() and askfont() methods in the font code. You need to take elements from callback() and askfont() and incorporate them into your code. You will also need to import the font code. Lets say the Font code is in the same directory as ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-03T19:28:43+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] How to bind classes to another widget\",\"datePublished\":\"2022-12-03T19:28:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\"},\"wordCount\":176,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"python\",\"python-3.x\",\"tkinter\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\",\"name\":\"[Solved] How to bind classes to another widget - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-12-03T19:28:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] How to bind classes to another widget\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] How to bind classes to another widget - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] How to bind classes to another widget - JassWeb","og_description":"[ad_1] Everything you need to make this work is located in the callback() and askfont() methods in the font code. You need to take elements from callback() and askfont() and incorporate them into your code. You will also need to import the font code. Lets say the Font code is in the same directory as ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/","og_site_name":"JassWeb","article_published_time":"2022-12-03T19:28:43+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] How to bind classes to another widget","datePublished":"2022-12-03T19:28:43+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/"},"wordCount":176,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["python","python-3.x","tkinter"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/","url":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/","name":"[Solved] How to bind classes to another widget - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-12-03T19:28:43+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-how-to-bind-classes-to-another-widget\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] How to bind classes to another widget"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/24568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=24568"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/24568\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=24568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=24568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=24568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}