|  | 
|  | 1 | +{ | 
|  | 2 | +  "CTkButton from the customtkinter module": { | 
|  | 3 | +    "prefix": "ctkbutton", | 
|  | 4 | +    "body": [ | 
|  | 5 | +      "def button_event():", | 
|  | 6 | +      "    print('button pressed')", | 
|  | 7 | +      "", | 
|  | 8 | +      "button = customtkinter.CTkButton(app, text='CTkButton', command=button_event)" | 
|  | 9 | +    ], | 
|  | 10 | +    "description": "Inserts a button widget snippet" | 
|  | 11 | +  }, | 
|  | 12 | +  "CTkCheckBox from the customtkinter module": { | 
|  | 13 | +    "prefix": "ctkcheckbox", | 
|  | 14 | +    "body": [ | 
|  | 15 | +      "def checkbox_event():", | 
|  | 16 | +      "    print('checkbox toggled, current value:', check_var.get())", | 
|  | 17 | +      "", | 
|  | 18 | +      "check_var = customtkinter.StringVar(value='on')", | 
|  | 19 | +      "checkbox = customtkinter.CTkCheckBox(app, text='CTkCheckBox', command=checkbox_event,", | 
|  | 20 | +      "                                     variable=check_var, onvalue='on', offvalue='off')" | 
|  | 21 | +    ], | 
|  | 22 | +    "description": "Inserts a checkbox widget snippet" | 
|  | 23 | +  }, | 
|  | 24 | +  "CTkComboBox from the customtkinter module": { | 
|  | 25 | +    "prefix": "ctkcombobox", | 
|  | 26 | +    "body": [ | 
|  | 27 | +      "def combobox_callback(choice):", | 
|  | 28 | +      "    print('combobox dropdown clicked:', choice)", | 
|  | 29 | +      "", | 
|  | 30 | +      "combobox_var = customtkinter.StringVar(value='option 2')", | 
|  | 31 | +      "combobox = customtkinter.CTkComboBox(app, values=['option 1', 'option 2'],", | 
|  | 32 | +      "                                     command=combobox_callback, variable=combobox_var)", | 
|  | 33 | +      "combobox_var.set('option 2')" | 
|  | 34 | +    ], | 
|  | 35 | +    "description": "Inserts a combo box widget snippet" | 
|  | 36 | +  }, | 
|  | 37 | +  "CTkEntry from the customtkinter module": { | 
|  | 38 | +    "prefix": "ctkentry", | 
|  | 39 | +    "body": [ | 
|  | 40 | +      "entry = customtkinter.CTkEntry(app, placeholder_text='CTkEntry')" | 
|  | 41 | +    ], | 
|  | 42 | +    "description": "Inserts an entry field widget snippet" | 
|  | 43 | +  }, | 
|  | 44 | +  "CTkFrane from the customtkinter module": { | 
|  | 45 | +    "prefix": "ctkframe", | 
|  | 46 | +    "body": [ | 
|  | 47 | +      "frame = customtkinter.CTkFrame(master=root_tk, width=200, height=200)" | 
|  | 48 | +    ], | 
|  | 49 | +    "description": "Inserts a frame widget snippet" | 
|  | 50 | +  }, | 
|  | 51 | +  "CTkLabel from the customtkinter module": { | 
|  | 52 | +    "prefix": "ctklabel", | 
|  | 53 | +    "body": [ | 
|  | 54 | +      "label = customtkinter.CTkLabel(app, text='CTkLabel', fg_color='transparent')" | 
|  | 55 | +    ], | 
|  | 56 | +    "description": "Inserts a label widget snippet" | 
|  | 57 | +  }, | 
|  | 58 | +  "CTkOptionMenu from the customtkinter module": { | 
|  | 59 | +    "prefix": "ctkoptionmenu", | 
|  | 60 | +    "body": [ | 
|  | 61 | +      "def optionmenu_callback(choice):", | 
|  | 62 | +      "    print('optionmenu dropdown clicked:', choice)", | 
|  | 63 | +      "", | 
|  | 64 | +      "optionmenu_var = customtkinter.StringVar(value='option 2')", | 
|  | 65 | +      "optionmenu = customtkinter.CTkOptionMenu(app,values=['option 1', 'option 2'],", | 
|  | 66 | +      "                                         command=optionmenu_callback,", | 
|  | 67 | +      "                                         variable=optionmenu_var)" | 
|  | 68 | +    ], | 
|  | 69 | +    "description": "Inserts an option menu widget snippet" | 
|  | 70 | +  }, | 
|  | 71 | +  "CTkProgressBar from the customtkinter module": { | 
|  | 72 | +    "prefix": "ctkprogressbar", | 
|  | 73 | +    "body": [ | 
|  | 74 | +      "progressbar = customtkinter.CTkProgressBar(app, orientation='horizontal')" | 
|  | 75 | +    ], | 
|  | 76 | +    "description": "Inserts a progress bar widget snippet" | 
|  | 77 | +  }, | 
|  | 78 | +  "CTkRadioButton from the customtkinter module": { | 
|  | 79 | +    "prefix": "ctkradiobutton", | 
|  | 80 | +    "body": [ | 
|  | 81 | +      "def radiobutton_event():", | 
|  | 82 | +      "    print('radiobutton toggled, current value:', radio_var.get())", | 
|  | 83 | +      "", | 
|  | 84 | +      "radio_var = tkinter.IntVar(value=0)", | 
|  | 85 | +      "radiobutton_1 = customtkinter.CTkRadioButton(app, text='CTkRadioButton 1',", | 
|  | 86 | +      "                                             command=radiobutton_event, variable= radio_var, value=1)", | 
|  | 87 | +      "radiobutton_2 = customtkinter.CTkRadioButton(app, text='CTkRadioButton 2',", | 
|  | 88 | +      "                                             command=radiobutton_event, variable= radio_var, value=2)" | 
|  | 89 | +    ], | 
|  | 90 | +    "description": "Inserts a radio button widget snippet" | 
|  | 91 | +  }, | 
|  | 92 | +  "CTkScrollableFrame from the customtkinter module": { | 
|  | 93 | +    "prefix": "ctkscrollableframe", | 
|  | 94 | +    "body": [ | 
|  | 95 | +      "scrollable_frame = customtkinter.CTkScrollableFrame(app, width=200, height=200)" | 
|  | 96 | +    ], | 
|  | 97 | +    "description": "Inserts a scrollable frame widget snippet" | 
|  | 98 | +  }, | 
|  | 99 | +  "CTkSegmentedButton from the customtkinter module": { | 
|  | 100 | +    "prefix": "ctksegmentedbutton", | 
|  | 101 | +    "body": [ | 
|  | 102 | +      "def segmented_button_callback(value):", | 
|  | 103 | +      "    print('segmented button clicked:', value)", | 
|  | 104 | +      "", | 
|  | 105 | +      "segemented_button_var = customtkinter.StringVar(value='Value 1')", | 
|  | 106 | +      "segemented_button = customtkinter.CTkSegmentedButton(app, values=['Value 1', 'Value 2', 'Value 3'],", | 
|  | 107 | +      "                                                     command=segmented_button_callback,", | 
|  | 108 | +      "                                                     variable=segemented_button_var)" | 
|  | 109 | +    ], | 
|  | 110 | +    "description": "Inserts a segmented button widget snippet" | 
|  | 111 | +  }, | 
|  | 112 | +  "CTkSlider from the customtkinter module": { | 
|  | 113 | +    "prefix": "ctkslider", | 
|  | 114 | +    "body": [ | 
|  | 115 | +      "def slider_event(value):", | 
|  | 116 | +      "    print(value)", | 
|  | 117 | +      "", | 
|  | 118 | +      "slider = customtkinter.CTkSlider(app, from_=0, to=100, command=slider_event)" | 
|  | 119 | +    ], | 
|  | 120 | +    "description": "Inserts a slider widget snippet" | 
|  | 121 | +  }, | 
|  | 122 | +  "CTkSwitch from the customtkinter module": { | 
|  | 123 | +    "prefix": "ctkswitch", | 
|  | 124 | +    "body": [ | 
|  | 125 | +      "def switch_event():", | 
|  | 126 | +      "    print('switch toggled, current value:', switch_var.get())", | 
|  | 127 | +      "", | 
|  | 128 | +      "switch_var = customtkinter.StringVar(value='on')", | 
|  | 129 | +      "switch = customtkinter.CTkSwitch(app, text='CTkSwitch', command=switch_event,", | 
|  | 130 | +      "                                 variable=switch_var, onvalue='on', offvalue='off')" | 
|  | 131 | +    ], | 
|  | 132 | +    "description": "Inserts a switch widget snippet" | 
|  | 133 | +  }, | 
|  | 134 | +  "CTkTabview from the customtkinter module": { | 
|  | 135 | +    "prefix": "ctktabview", | 
|  | 136 | +    "body": [ | 
|  | 137 | +      "tabview = customtkinter.CTkTabview(master=app)", | 
|  | 138 | +      "tabview.pack(padx=20, pady=20)", | 
|  | 139 | +      "", | 
|  | 140 | +      "tabview.add('tab 1')  # add tab at the end", | 
|  | 141 | +      "tabview.add('tab 2')  # add tab at the end", | 
|  | 142 | +      "tabview.set('tab 2')  # set currently visible tab", | 
|  | 143 | +      "", | 
|  | 144 | +      "button = customtkinter.CTkButton(master=tabview.tab('tab 1'))", | 
|  | 145 | +      "button.pack(padx=20, pady=20)" | 
|  | 146 | +    ], | 
|  | 147 | +    "description": "Inserts a tab view widget snippet" | 
|  | 148 | +  }, | 
|  | 149 | +  "CTkTextbox from the customtkinter module": { | 
|  | 150 | +    "prefix": "ctktextbox", | 
|  | 151 | +    "body": [ | 
|  | 152 | +      "textbox = customtkinter.CTkTextbox(app)", | 
|  | 153 | +      "", | 
|  | 154 | +      "textbox.insert('0.0', 'new text to insert')  # insert at line 0 character 0", | 
|  | 155 | +      "text = textbox.get('0.0', 'end')  # get text from line 0 character 0 till the end", | 
|  | 156 | +      "textbox.delete('0.0', 'end')  # delete all text", | 
|  | 157 | +      "textbox.configure(state='disabled')  # configure textbox to be read-only" | 
|  | 158 | +    ], | 
|  | 159 | +    "description": "Inserts a textbox widget snippet" | 
|  | 160 | +  }, | 
|  | 161 | +  "CTkScrollbar from the customtkinter module": { | 
|  | 162 | +    "prefix": "ctkscrollbar", | 
|  | 163 | +    "body": [ | 
|  | 164 | +      "tk_textbox = customtkinter.CTkTextbox(app, activate_scrollbars=False)", | 
|  | 165 | +      "tk_textbox.grid(row=0, column=0, sticky='nsew')", | 
|  | 166 | +      "", | 
|  | 167 | +      "# create CTk scrollbar", | 
|  | 168 | +      "ctk_textbox_scrollbar = customtkinter.CTkScrollbar(app, command=tk_textbox.yview)", | 
|  | 169 | +      "ctk_textbox_scrollbar.grid(row=0, column=1, sticky='ns')", | 
|  | 170 | +      "", | 
|  | 171 | +      "# connect textbox scroll event to CTk scrollbar", | 
|  | 172 | +      "tk_textbox.configure(yscrollcommand=ctk_textbox_scrollbar.set)" | 
|  | 173 | +    ], | 
|  | 174 | +    "description": "Inserts a scrollbar widget snippet" | 
|  | 175 | +  }, | 
|  | 176 | +  "CTk from the customtkinter module": { | 
|  | 177 | +    "prefix": "ctkwindow", | 
|  | 178 | +    "body": [ | 
|  | 179 | +      "import customtkinter", | 
|  | 180 | +      "", | 
|  | 181 | +      "app = customtkinter.CTk()", | 
|  | 182 | +      "app.geometry('600x500')", | 
|  | 183 | +      "app.title('CTk example')", | 
|  | 184 | +      "", | 
|  | 185 | +      "def button_event():", | 
|  | 186 | +      "    print('button pressed')", | 
|  | 187 | +      "", | 
|  | 188 | +      "button = customtkinter.CTkButton(app, text='CTkButton', command=button_event)", | 
|  | 189 | +      "", | 
|  | 190 | +      "app.mainloop()" | 
|  | 191 | +    ], | 
|  | 192 | +    "description": "Creates a base CustomTkinter window" | 
|  | 193 | +  }, | 
|  | 194 | +  "CTkImage from the customtkinter module": { | 
|  | 195 | +    "prefix": "ctkimage", | 
|  | 196 | +    "body": [ | 
|  | 197 | +      "# add `from PIL import Image` on top", | 
|  | 198 | +      "my_image = customtkinter.CTkImage(light_image=Image.open('<path to light mode image>'),", | 
|  | 199 | +      "                                  dark_image=Image.open('<path to dark mode image>'),", | 
|  | 200 | +      "                                  size=(30, 30))", | 
|  | 201 | +      "", | 
|  | 202 | +      "image_label = customtkinter.CTkLabel(app, image=my_image, text='')  # display image with a CTkLabel" | 
|  | 203 | +    ], | 
|  | 204 | +    "description": "Image" | 
|  | 205 | +  }, | 
|  | 206 | +  "CTkFont from the customtkinter module": { | 
|  | 207 | +    "prefix": "ctkfont", | 
|  | 208 | +    "body": [ | 
|  | 209 | +      "my_font = customtkinter.CTkFont(family='<family name>', size=<size in px>, <optional keyword arguments>)" | 
|  | 210 | +    ], | 
|  | 211 | +    "description": "Font" | 
|  | 212 | +  }, | 
|  | 213 | +  "CTkToplevel from the customtkinter module": { | 
|  | 214 | +    "prefix": "ctktoplevel", | 
|  | 215 | +    "body": ["toplevel = CTkToplevel(app)  # master argument is optional  "], | 
|  | 216 | +    "description": "Inserts a top-level window widget snippet" | 
|  | 217 | +  }, | 
|  | 218 | +  "CTkInputDialog from the customtkinter module": { | 
|  | 219 | +    "prefix": "ctkinputdialog", | 
|  | 220 | +    "body": [ | 
|  | 221 | +      "dialog = customtkinter.CTkInputDialog(text='Type in a number:', title='Test')", | 
|  | 222 | +      "text = dialog.get_input()" | 
|  | 223 | +    ], | 
|  | 224 | +    "description": "Inserts an input dialog widget snippet" | 
|  | 225 | +  }, | 
|  | 226 | +  "Appearance Mode from the customtkinter module": { | 
|  | 227 | +    "prefix": "appsys", | 
|  | 228 | +    "body": ["customtkinter.set_appearance_mode('system')"], | 
|  | 229 | +    "description": "Copy systems appearance" | 
|  | 230 | +  }, | 
|  | 231 | +  "Appearance Mode Dark from the customtkinter module": { | 
|  | 232 | +    "prefix": "appdark", | 
|  | 233 | +    "body": ["customtkinter.set_appearance_mode('dark')"], | 
|  | 234 | +    "description": "Sets appearance to be dark" | 
|  | 235 | +  }, | 
|  | 236 | +  "Appearance Mode Light from the customtkinter module": { | 
|  | 237 | +    "prefix": "applight", | 
|  | 238 | +    "body": ["customtkinter.set_appearance_mode('light')"], | 
|  | 239 | +    "description": "Sets appearance mode to be light" | 
|  | 240 | +  }, | 
|  | 241 | +  "Theme Green from the customtkinter module": { | 
|  | 242 | +    "prefix": "themegreen", | 
|  | 243 | +    "body": ["customtkinter.set_default_color_theme('green')"], | 
|  | 244 | +    "description": "Sets the theme of the app to be green" | 
|  | 245 | +  }, | 
|  | 246 | +  "Theme Blue from the customtkinter module": { | 
|  | 247 | +    "prefix": "themeblue", | 
|  | 248 | +    "body": ["customtkinter.set_default_color_theme('blue')"], | 
|  | 249 | +    "description": "Sets the theme of the app to be blue" | 
|  | 250 | +  }, | 
|  | 251 | +  "Theme Dark Blue from the customtkinter module": { | 
|  | 252 | +    "prefix": "themedarkblue", | 
|  | 253 | +    "body": ["customtkinter.set_default_color_theme('dark-blue')"], | 
|  | 254 | +    "description": "Sets the theme of the app to be dark-blue" | 
|  | 255 | +  }, | 
|  | 256 | +  "Theme Custom from the customtkinter module": { | 
|  | 257 | +    "prefix": "theme", | 
|  | 258 | +    "body": [ | 
|  | 259 | +      "customtkinter.set_default_color_theme('path/to/your/custom_theme.json')" | 
|  | 260 | +    ], | 
|  | 261 | +    "description": "Sets custom theme for the app" | 
|  | 262 | +  }, | 
|  | 263 | +  "Scaling Widget from the customtkinter module": { | 
|  | 264 | +    "prefix": "scalingwidget", | 
|  | 265 | +    "body": ["customtkinter.set_widget_scaling(float_value)"], | 
|  | 266 | +    "description": "Sets the scale of the widgets with-in the app" | 
|  | 267 | +  }, | 
|  | 268 | +  "Scaling Window from the customtkinter module": { | 
|  | 269 | +    "prefix": "scalingwindow", | 
|  | 270 | +    "body": ["customtkinter.set_window_scaling(float_value)"], | 
|  | 271 | +    "description": "Sets the scale of the apps window" | 
|  | 272 | +  }, | 
|  | 273 | +  "Deactivate DPI from the customtkinter module": { | 
|  | 274 | +    "prefix": "dpideactivate", | 
|  | 275 | +    "body": ["customtkinter.deactivate_automatic_dpi_awareness()"], | 
|  | 276 | +    "description": "Deactivates automatic scaling" | 
|  | 277 | +  } | 
|  | 278 | +} | 
0 commit comments