|
| 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": "Button" |
| 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": "Check Box" |
| 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": "Combo Box" |
| 36 | + }, |
| 37 | + "CTkEntry from the customtkinter module": { |
| 38 | + "prefix": "ctkentry", |
| 39 | + "body": [ |
| 40 | + "entry = customtkinter.CTkEntry(app, placeholder_text='CTkEntry')" |
| 41 | + ], |
| 42 | + "description": "Entry" |
| 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": "Frame" |
| 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": "Label" |
| 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": "Option Menu" |
| 70 | + }, |
| 71 | + "CTkProgressBar from the customtkinter module": { |
| 72 | + "prefix": "ctkprogressbar", |
| 73 | + "body": [ |
| 74 | + "progressbar = customtkinter.CTkProgressBar(app, orientation='horizontal')" |
| 75 | + ], |
| 76 | + "description": "Progress Bar" |
| 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": "Radio Button" |
| 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": "Scrollable Frame" |
| 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": "Segmented Button" |
| 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": "Slider" |
| 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": "Switch" |
| 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": "Tabview" |
| 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": "Textbox" |
| 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": "Scrollbar" |
| 175 | + }, |
| 176 | + "CTk from the customtkinter module": { |
| 177 | + "prefix": "ctkwindow", |
| 178 | + "body": [ |
| 179 | + "app = customtkinter.CTk()", |
| 180 | + "app.geometry('600x500')", |
| 181 | + "app.title('CTk example')", |
| 182 | + "", |
| 183 | + "def button_event():", |
| 184 | + " print('button pressed')", |
| 185 | + "", |
| 186 | + "button = customtkinter.CTkButton(app, text='CTkButton', command=button_event)", |
| 187 | + "", |
| 188 | + "app.mainloop()" |
| 189 | + ], |
| 190 | + "description": "Window" |
| 191 | + }, |
| 192 | + "CTkImage from the customtkinter module": { |
| 193 | + "prefix": "ctkimage", |
| 194 | + "body": [ |
| 195 | + "# import PIL on top", |
| 196 | + "my_image = customtkinter.CTkImage(light_image=Image.open('<path to light mode image>'),", |
| 197 | + " dark_image=Image.open('<path to dark mode image>'),", |
| 198 | + " size=(30, 30))", |
| 199 | + "", |
| 200 | + "image_label = customtkinter.CTkLabel(app, image=my_image, text='') # display image with a CTkLabel" |
| 201 | + ], |
| 202 | + "description": "Image" |
| 203 | + }, |
| 204 | + "CTkFont from the customtkinter module": { |
| 205 | + "prefix": "ctkfont", |
| 206 | + "body": [ |
| 207 | + "my_font = customtkinter.CTkFont(family='<family name>', size=<size in px>, <optional keyword arguments>)" |
| 208 | + ], |
| 209 | + "description": "Font" |
| 210 | + }, |
| 211 | + "CTkToplevel from the customtkinter module": { |
| 212 | + "prefix": "ctktoplevel", |
| 213 | + "body": ["toplevel = CTkToplevel(app) # master argument is optional "], |
| 214 | + "description": "Toplevel" |
| 215 | + }, |
| 216 | + "CTkInputDialog from the customtkinter module": { |
| 217 | + "prefix": "ctkinputdialog", |
| 218 | + "body": [ |
| 219 | + "dialog = customtkinter.CTkInputDialog(text='Type in a number:', title='Test')", |
| 220 | + "text = dialog.get_input()" |
| 221 | + ], |
| 222 | + "description": "Input Dialog" |
| 223 | + }, |
| 224 | + "Appearance Mode from the customtkinter module": { |
| 225 | + "prefix": "appsys", |
| 226 | + "body": ["customtkinter.set_appearance_mode('system')"], |
| 227 | + "description": "Copy systems appearance" |
| 228 | + }, |
| 229 | + "Appearance Mode Dark from the customtkinter module": { |
| 230 | + "prefix": "appdark", |
| 231 | + "body": ["customtkinter.set_appearance_mode('dark')"], |
| 232 | + "description": "Sets appearance to be dark" |
| 233 | + }, |
| 234 | + "Appearance Mode Light from the customtkinter module": { |
| 235 | + "prefix": "applight", |
| 236 | + "body": ["customtkinter.set_appearance_mode('light')"], |
| 237 | + "description": "Sets appearance mode to be light" |
| 238 | + }, |
| 239 | + "Theme Green from the customtkinter module": { |
| 240 | + "prefix": "themegreen", |
| 241 | + "body": ["customtkinter.set_default_color_theme('green')"], |
| 242 | + "description": "Sets the theme of the app to be green" |
| 243 | + }, |
| 244 | + "Theme Blue from the customtkinter module": { |
| 245 | + "prefix": "themeblue", |
| 246 | + "body": ["customtkinter.set_default_color_theme('blue')"], |
| 247 | + "description": "Sets the theme of the app to be blue" |
| 248 | + }, |
| 249 | + "Theme Dark Blue from the customtkinter module": { |
| 250 | + "prefix": "themedarkblue", |
| 251 | + "body": ["customtkinter.set_default_color_theme('dark-blue')"], |
| 252 | + "description": "Sets the theme of the app to be dark-blue" |
| 253 | + }, |
| 254 | + "Theme Custom from the customtkinter module": { |
| 255 | + "prefix": "theme", |
| 256 | + "body": [ |
| 257 | + "customtkinter.set_default_color_theme('path/to/your/custom_theme.json')" |
| 258 | + ], |
| 259 | + "description": "Sets custom theme for the app" |
| 260 | + }, |
| 261 | + "Scaling Widget from the customtkinter module": { |
| 262 | + "prefix": "scalingwidget", |
| 263 | + "body": ["customtkinter.set_widget_scaling(float_value)"], |
| 264 | + "description": "Sets the scale of the widgets with-in the app" |
| 265 | + }, |
| 266 | + "Scaling Window from the customtkinter module": { |
| 267 | + "prefix": "scalingwindow", |
| 268 | + "body": ["customtkinter.set_window_scaling(float_value)"], |
| 269 | + "description": "Sets the scale of the apps window" |
| 270 | + }, |
| 271 | + "Deactivate DPI from the customtkinter module": { |
| 272 | + "prefix": "dpideactivate", |
| 273 | + "body": ["customtkinter.deactivate_automatic_dpi_awareness()"], |
| 274 | + "description": "Deactivates automatic scaling" |
| 275 | + } |
| 276 | +} |
0 commit comments