Advertisement
here2share

# Tk_quickrun_fix.py

Feb 1st, 2020
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 28.73 KB | None | 0 0
  1. # Tk_quickrun_fix.py
  2.  
  3. from Tkinter import *
  4. import os
  5. cls=lambda: os.system('cls')
  6.  
  7. ttt='''# enter_filename_here.py
  8.  
  9. # -- patchwork --
  10.  
  11. from Tkinter import *
  12. import Tkinter as tk
  13. from PIL import Image
  14. from PIL import ImageTk
  15. import tkFileDialog
  16. import tkMessageBox
  17. import tkFont
  18. import Tkconstants
  19. from tkFileDialog import askopenfilename
  20. from tkFileDialog import asksaveasfilename
  21.  
  22. try:
  23.     import urllib.request as url
  24. except ImportError:
  25.     import urllib as url
  26.  
  27. temp_root=Tk()
  28.  
  29. t=tkFont.families()
  30. tk_fonts=[]
  31. for font in t:
  32.     if not '@' in font:
  33.         tk_fonts.append(font)
  34.         # print(font)
  35. temp_root.withdraw()   
  36.  
  37.  
  38. # -- end --
  39. '''
  40.  
  41. zzz='''
  42. tkinter             Tkinter
  43. messagebox.         tkMessageBox.
  44. filedialog.         tkFileDialog.
  45. ttk.           
  46. .ttk           
  47. '''[:-1].splitlines()
  48.  
  49. z2='''
  50. messagebox
  51. filedialog
  52. Image
  53. ImageTk
  54. '''[:-1].splitlines()
  55.  
  56. eval=ttt
  57. root=Tk('200X200+1+1')
  58.  
  59. valid=''
  60. for z in range(33,127):
  61.     valid += chr(z)
  62. valid=valid + ' ' + '   '
  63. print valid
  64.  
  65. import tkFont
  66. t=tkFont.families()
  67. tk_fonts=[]
  68. for font in t:
  69.     if not '@' in font:
  70.         tk_fonts.append(font)
  71.         # print(font)  
  72.  
  73. def clipb():
  74.     def repl(z):
  75.         while '\t\t' in z: z=z.replace('\t\t','\t')
  76.         try:
  77.             a,b=z.split('\t')
  78.         except:
  79.             return t
  80.         return t.replace(a,b)
  81.     def encl(z):
  82.         d=[]
  83.         parentheses={')':'(','}':'{',']':'[','"':'"',"'":"'"}
  84.         s2=sss[sss.index(z):]
  85.         for n,s in enumerate(s2):
  86.             if s == ',' and d == []:
  87.                 return s2[:s2.index(s)+1]
  88.             elif s in '[({':
  89.                 d.append(s)
  90.             elif s in '])}':
  91.                 try:
  92.                     d.remove(parentheses[s])
  93.                 except:
  94.                     return s2[:n]
  95.         t,t2=max([([sss.rindex(z),z] if z in sss else [0,'']) for z in '])}'])
  96.         if t2:
  97.             return sss[:t+1]
  98.         return ''
  99.     try:
  100.         t=root.clipboard_get()
  101.     except:
  102.         cls()
  103.         print '*** Invalid ***'
  104.         return
  105.     if t.strip():
  106.         for z in zzz:
  107.             t=repl(z)
  108.         d=[]
  109.         t=t.replace('    ','    ') # note: does not work in console but from clipboard
  110.         for sss in t.splitlines():
  111.             if 'import' in sss:
  112.                 for z in z2:
  113.                     if ' '+z in t:
  114.                         sss=''
  115.             elif 'font' in sss:
  116.                 s2=encl('font')
  117.                 font='normal'
  118.                 for z in tk_fonts:
  119.                     if z in s2:
  120.                         font=z
  121.             if sss:
  122.                 s=''
  123.                 for z in sss:
  124.                     if z in valid:
  125.                         s += z
  126.                     else:
  127.                         s += '/'
  128.                 if all([(z in s) for z in ('//','#')]):
  129.                     s=s.split('#')[0]
  130.                 d.append(s.rstrip())
  131.         t=[ttt]+d
  132.         cls()
  133.         for i in t:
  134.             try:
  135.                 print i
  136.             except:
  137.                 print '???'
  138.         t='\n'.join(t)
  139.         root.clipboard_clear()
  140.         root.clipboard_append(t)
  141.  
  142. Frame=LabelFrame(root,height=50,width=250,borderwidth=0,bg="light blue") # note: width=200 minimal
  143. Frame.pack(fill=X)
  144. Frame.pack_propagate(False)
  145.  
  146. Label(Frame,text="Show Copy Revised In Cleared Console",bg="light blue").pack()
  147.  
  148. cpb=Button(Frame,text="Copy From Clipboard",command=clipb)
  149. cpb.pack()
  150.  
  151. root.mainloop()
  152.  
  153. '''
  154. root=Tk("%dx%d+1+1"%(h,w))
  155.  
  156. root.minsize(w,h)
  157.  
  158. """ >>>
  159. root=Tk()
  160.  
  161. root.geometry("%dx%d+1+1"%(h,w))
  162. """
  163.  
  164. canvas=Canvas(root ,bg="yellow", height="200", width=200)  
  165.  
  166. arc=canvas.create_arc((5,10,150,200), start=0, extent=150, fill="purple")  
  167.  
  168. canvas.pack()
  169.  
  170. """
  171. Button              The Button is used to add various kinds of buttons to the python application.
  172.  
  173. Canvas              The canvas widget is used to draw the canvas on the window.
  174.  
  175. Checkbutton         The Checkbutton is used to display the CheckButton on the window.
  176.  
  177. Entry               The entry widget is used to display the single-line text field to the user. It is commonly used to accept user values.
  178.  
  179. Frame               It can be defined as a container to which, another widget can be added and organized.
  180.  
  181. Label               A label is a text used to display some message or information about the other widgets.
  182.  
  183. ListBox             The ListBox widget is used to display a list of options to the user.
  184.  
  185. Menubutton          The Menubutton is used to display the menu items to the user.
  186.  
  187. Menu                It is used to add menu items to the user.
  188.  
  189. Message             The Message widget is used to display the message-box to the user.
  190.  
  191. Radiobutton         The Radiobutton is different from a checkbutton. Here, the user is provided with various options and the user can select only one option among them.
  192.  
  193. Scale               It is used to provide the slider to the user.
  194.  
  195. Scrollbar           It provides the scrollbar to the user so that the user can scroll the window up and down.
  196.  
  197. Text                It is different from Entry because it provides a multi-line text field to the user so that the user can write the text and edit the text inside it.
  198.  
  199. Toplevel            It is used to create a separate window container.
  200.  
  201. Spinbox             It is an entry widget used to select from options of values.
  202.  
  203. PanedWindow         It is like a container widget that contains horizontal or vertical panes.
  204.  
  205. LabelFrame          A LabelFrame is a container widget that acts as the container
  206.  
  207. MessageBox          This module is used to display the message-box in the desktop based applications.
  208.  
  209. ###
  210.  
  211. The pack() method
  212.  
  213. The grid() method
  214.  
  215. The place() method
  216.  
  217. ###
  218.  
  219. Grid:
  220.  
  221. Column: The column number in which the widget is to be placed. The leftmost column is represented by
  222.  
  223. Columnspan: The width of the widget. It represents the number of columns up to which, the column is expanded.
  224.  
  225. ipadx, ipady: It represents the number of pixels to pad the widget inside the widget's border.
  226.  
  227. padx, pady: It represents the number of pixels to pad the widget outside the widget's border.
  228.  
  229. row: The row number in which the widget is to be placed. The topmost row is represented by
  230.  
  231. rowspan: The height of the widget, i.e. the number of the row up to which the widget is expanded.
  232.  
  233. Sticky: If the cell is larger than a widget, then sticky is used to specify the position of the widget inside the cell. It may be the concatenation of the sticky letters representing the position of the widget. It may be N, E, W, S, NE, NW, NS, EW, ES.
  234.  
  235. ###
  236.  
  237. Pack:
  238.  
  239. expand: If the expand is set to true, the widget expands to fill any space.
  240.  
  241. Fill: By default, the fill is set to NONE. However, we can set it to X or Y to determine whether the widget contains any extra space.
  242.  
  243. size: it represents the side of the parent to which the widget is to be placed on the window.
  244.  
  245.  
  246. ###
  247.  
  248. Place:
  249.  
  250. Anchor: It represents the exact position of the widget within the container. The default value (direction) is NW (the upper left corner)
  251.  
  252. bordermode: The default value of the border type is INSIDE that refers to ignore the parent's inside the border. The other option is OUTSIDE.
  253.  
  254. height, width: It refers to the height and width in pixels.
  255.  
  256. relheight, relwidth: It is represented as the float between and indicating the fraction of the parent's height and width.
  257.  
  258. relx, rely: It is represented as the float between and that is the offset in the horizontal and vertical direction.
  259.  
  260. x, y: It refers to the horizontal and vertical offset in the pixels.
  261.  
  262.  
  263. """
  264.  
  265. tkMessageBox.askokcancel("Title","The application will be closed")
  266.  
  267. tkMessageBox.askyesno("Title","Do you want to save?")
  268.  
  269. tkMessageBox.askretrycancel("Title","Installation failed, try again?")
  270.  
  271. tkMessageBox.showinfo("Info","Information...")
  272.  
  273. tkMessageBox.showwarning("Warning","Warning...")
  274.  
  275. tkMessageBox.showerror("Error","Error...")
  276.  
  277. tkMessageBox.askquestion("Confirm","Exit?")
  278.  
  279. def button_callback():
  280.    print "click!"
  281.  
  282. b=Button(root, text="OK", command=button_callback)
  283. """ >>>
  284. -- OR --
  285. b=Button(root, image=photo, command=button_callback, height= width=
  286. """
  287.  
  288. b.pack()
  289. """ >>>
  290. -- OR --
  291. b.grid()
  292. -- OR --
  293. b.place()
  294. """
  295.  
  296. """
  297. activebackground    It represents the background of the button when the mouse hover the button.
  298.  
  299. activeforeground    It represents the font color of the button when the mouse hover the button.
  300.  
  301. Bd                  It represents the border width in pixels.
  302.  
  303. Bg                  It represents the background color of the button.
  304.  
  305. Command             It is set to the function call which is scheduled when the function is called.
  306.  
  307. Fg                  Foreground color of the button.
  308.  
  309. Font                The font of the button text.
  310.  
  311. Height              The height of the button. The height is represented in the number of text lines for the textual lines or the number of pixels for the images.
  312.  
  313. Highlightcolor      The color of the highlight when the button has the focus.
  314.  
  315. Image               It is set to the image displayed on the button.
  316.  
  317. justify             It illustrates the way by which the multiple text lines are represented. It is set to LEFT for left justification, RIGHT for the right justification, and CENTER for the center.
  318.  
  319. Padx                Additional padding to the button in the horizontal direction.
  320.  
  321. pady                Additional padding to the button in the vertical direction.
  322.  
  323. Relief              It represents the type of the border. It can be SUNKEN, RAISED, GROOVE, and RIDGE.
  324.  
  325. State               This option is set to DISABLED to make the button unresponsive. The ACTIVE represents the active state of the button.
  326.  
  327. Underline           Set this option to make the button text underlined.
  328.  
  329. Width               The width of the button. It exists as a number of letters for textual buttons or pixels for image buttons.
  330.  
  331. Wraplength          If the value is set to a positive number, the text lines will be wrapped to fit within this length.
  332. """
  333.  
  334. var=StringVar()
  335. textbox=Entry(root, textvariable=var)
  336. textbox.focus_set()
  337. textbox.pack(pady= padx=
  338.  
  339. """
  340. bg                      The background color of the widget.
  341.  
  342. bd                      The border width of the widget in pixels.
  343.  
  344. cursor                  The mouse pointer will be changed to the cursor type set to the arrow, dot, etc.
  345.  
  346. exportselection         The text written inside the entry box will be automatically copied to the clipboard by default. We can set the exportselection to to not copy this.
  347.  
  348. fg                      It represents the color of the text.
  349.  
  350. font                    It represents the font type of the text.
  351.  
  352. highlightbackground     It represents the color to display in the traversal highlight region when the widget does not have the input focus.
  353.  
  354. highlightcolor          It represents the color to use for the traversal highlight rectangle that is drawn around the widget when it has the input focus.
  355.  
  356. highlightthickness      It represents a non-negative value indicating the width of the highlight rectangle to draw around the outside of the widget when it has the input focus.
  357.  
  358. insertbackground        It represents the color to use as background in the area covered by the insertion cursor. This color will normally override either the normal background for the widget.
  359.  
  360. insertborderwidth       It represents a non-negative value indicating the width of the D border to draw around the insertion cursor. The value may have any of the forms acceptable to Tk_GetPixels.
  361.  
  362. insertofftime           It represents a non-negative integer value indicating the number of milliseconds the insertion cursor should remain "off" in each blink cycle. If this option is zero, then the cursor doesn't blink: it is on all the time.
  363.  
  364. insertontime            Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain "on" in each blink cycle.
  365.  
  366. insertwidth             It represents the value indicating the total width of the insertion cursor. The value may have any of the forms acceptable to Tk_GetPixels.
  367.  
  368. justify                 It specifies how the text is organized if the text contains multiple lines.
  369.  
  370. relief                  It specifies the type of the border. Its default value is FLAT.
  371.  
  372. selectbackground        The background color of the selected text.
  373.  
  374. selectborderwidth       The width of the border to display around the selected task.
  375.  
  376. selectforeground        The font color of the selected task.
  377.  
  378. show                    It is used to show the entry text of some other type instead of the string. For example, the password is typed using stars (*).
  379.  
  380. textvariable            It is set to the instance of the StringVar to retrieve the text from the entry.
  381.  
  382. width                   The width of the displayed text or image.
  383.  
  384. xscrollcommand          The entry widget can be linked to the horizontal scrollbar if we want the user to enter more text then the actual width of the widget.
  385.  
  386. ###
  387.  
  388. delete(first, last=none)        It is used to delete the specified characters inside the widget.
  389.  
  390. get()                           It is used to get the text written inside the widget.
  391.  
  392. icursor(index)                  It is used to change the insertion cursor position. We can specify the index of the character before which, the cursor to be placed.
  393.  
  394. index(index)                    It is used to place the cursor to the left of the character written at the specified index.
  395.  
  396. insert(index,s)                 It is used to insert the specified string before the character placed at the specified index.
  397.  
  398. select_adjust(index)            It includes the selection of the character present at the specified index.
  399.  
  400. select_clear()                  It clears the selection if some selection has been done.
  401.  
  402. select_form(index)              It sets the anchor index position to the character specified by the index.
  403.  
  404. select_present()                It returns true if some text in the Entry is selected otherwise returns false.
  405.  
  406. select_range(start,end)         It selects the characters to exist between the specified range.
  407.  
  408. select_to(index)                It selects all the characters from the beginning to the specified index.
  409.  
  410. xview(index)                    It is used to link the entry widget to a horizontal scrollbar.
  411.  
  412. xview_scroll(number,what)       It is used to make the entry scrollable horizontally.
  413. """
  414.  
  415. checkvarIntVar()  
  416.  
  417. checkvarIntVar()  
  418.  
  419. checkvarIntVar()  
  420.  
  421. chkbtnCheckbutton(root, text="A", variable=checkvar onvalue= offvalue= height= width=  
  422.  
  423. chkbtnCheckbutton(root, text="B", variable=checkvar onvalue= offvalue= height= width=  
  424.  
  425. chkbtnCheckbutton(root, text="C", variable=checkvar onvalue= offvalue= height= width=  
  426.  
  427. chkbtnpack()  
  428.  
  429. chkbtnpack()  
  430.  
  431. chkbtnpack()
  432.  
  433. """
  434. activebackground        It represents the background color when the checkbutton is under the cursor.
  435.  
  436. activeforeground        It represents the foreground color of the checkbutton when the checkbutton is under the cursor.
  437.  
  438. bg                      The background color of the button.
  439.  
  440. bitmap                  It displays an image (monochrome) on the button.
  441.  
  442. bd                      The size of the border around the corner.
  443.  
  444. command                 It is associated with a function to be called when the state of the checkbutton is changed.
  445.  
  446. cursor                  The mouse pointer will be changed to the cursor name when it is over the checkbutton.
  447.  
  448. disableforeground       It is the color which is used to represent the text of a disabled checkbutton.
  449.  
  450. font                    It represents the font of the checkbutton.
  451.  
  452. fg                      The foreground color (text color) of the checkbutton.
  453.  
  454. height                  It represents the height of the checkbutton (number of lines). The default height is highlightcolor     The color of the focus highlight when the checkbutton is under focus.
  455.  
  456. image                   The image used to represent the checkbutton.
  457.  
  458. justify                 This specifies the justification of the text if the text contains multiple lines.
  459.  
  460. offvalue                The associated control variable is set to by default if the button is unchecked. We can change the state of an unchecked variable to some other one.
  461.  
  462. onvalue                 The associated control variable is set to by default if the button is checked. We can change the state of the checked variable to some other one.
  463.  
  464. padx                    The horizontal padding of the checkbutton
  465.  
  466. pady                    The vertical padding of the checkbutton.
  467.  
  468. relief                  The type of the border of the checkbutton. By default, it is set to FLAT.
  469.  
  470. selectcolor             The color of the checkbutton when it is set. By default, it is red.
  471.  
  472. selectimage             The image is shown on the checkbutton when it is set.
  473.  
  474. state                   It represents the state of the checkbutton. By default, it is set to normal. We can change it to DISABLED to make the checkbutton unresponsive. The state of the checkbutton is ACTIVE when it is under focus.
  475.  
  476. underline               It represents the index of the character in the text which is to be underlined. The indexing starts with zero in the text.
  477.  
  478. variable                It represents the associated variable that tracks the state of the checkbutton.
  479.  
  480. width                   It represents the width of the checkbutton. It is represented in the number of characters that are represented in the form of texts.
  481.  
  482. wraplength              If this option is set to an integer number, the text will be broken into the number of pieces.
  483.  
  484. ###
  485.  
  486. deselect()      It is called to turn off the checkbutton.
  487.  
  488. flash()         The checkbutton is flashed between the active and normal colors.
  489.  
  490. invoke()        This will invoke the method associated with the checkbutton.
  491.  
  492. select()        It is called to turn on the checkbutton.
  493.  
  494. toggle()        It is used to toggle between the different Checkbuttons.
  495. """
  496.  
  497. img=PhotoImage(file="pylogo.png")
  498. panel=Label(root, image=img)
  499. panel.pack(side="bottom", fill="both", expand="yes")
  500.  
  501. root.title('Hello')
  502. a=Label(root, text='Hello World!')
  503. a.pack(pady=padx=
  504.  
  505. def donothing():
  506.   pass
  507.  
  508. frame=Frame(root)  
  509. frame.pack()  
  510.  
  511. leftframe=Frame(root)  
  512. leftframe.pack(side=LEFT)  
  513.  
  514. rightframe=Frame(root)  
  515. rightframe.pack(side=RIGHT)
  516.  
  517. """
  518. bd                      It represents the border width.
  519.  
  520. bg                      The background color of the widget.
  521.  
  522. cursor                  The mouse pointer is changed to the cursor type set to different values like an arrow, dot, etc.
  523.  
  524. height                  The height of the frame.
  525.  
  526. highlightbackground     The color of the background color when it is under focus.
  527.  
  528. highlightcolor          The text color when the widget is under focus.
  529.  
  530. highlightthickness      It specifies the thickness around the border when the widget is under the focus.
  531.  
  532. relief                  It specifies the type of the border. The default value if FLAT.
  533.  
  534. width                   It represents the width of the widget.
  535. """
  536.  
  537. btnButton(frame, text="Submit", fg="red",activebackground="red")  
  538. btnpack(side=LEFT)  
  539.  
  540. btnButton(frame, text="Remove", fg="brown", activebackground="brown")  
  541. btnpack(side=RIGHT)  
  542.  
  543. btnButton(rightframe, text="Add", fg="blue", activebackground="blue")  
  544. btnpack(side=LEFT)  
  545.  
  546. btnButton(leftframe, text="Modify", fg="black", activebackground="white")  
  547. btnpack(side=RIGHT)
  548.  
  549. listbox=Listbox(root)  
  550. listbox.insert( "Item A")
  551. listbox.insert( "Item B")
  552. listbox.insert( "Item C")
  553. listbox.insert( "Item D")
  554.  
  555. btn=Button(root, text="delete", command=lambda listbox=listbox: listbox.delete(ANCHOR))  
  556. listbox.pack()  
  557. btn.pack()  
  558.  
  559. """
  560. activate(index)                 It is used to select the lines at the specified index.
  561.  
  562. curselection()                  It returns a tuple containing the line numbers of the selected element or elements, counting from If nothing is selected, returns an empty tuple.
  563.  
  564. delete(first, last=None)        It is used to delete the lines which exist in the given range.
  565.  
  566. get(first, last=None)           It is used to get the list items that exist in the given range.
  567.  
  568. index(i)                        It is used to place the line with the specified index at the top of the widget.
  569.  
  570. insert(index, *elements)        It is used to insert the new lines with the specified number of elements before the specified index.
  571.  
  572. nearest(y)                      It returns the index of the nearest line to the y coordinate of the Listbox widget.
  573.  
  574. see(index)                      It is used to adjust the position of the listbox to make the lines specified by the index visible.
  575.  
  576. size()                          It returns the number of lines that are present in the Listbox widget.
  577.  
  578. xview()                         This is used to make the widget horizontally scrollable.
  579.  
  580. xview_moveto(fraction)          It is used to make the listbox horizontally scrollable by the fraction of width of the longest line present in the listbox.
  581.  
  582. xview_scroll(number, what)      It is used to make the listbox horizontally scrollable by the number of characters specified.
  583.  
  584. yview()                         It allows the Listbox to be vertically scrollable.
  585.  
  586. yview_moveto(fraction)          It is used to make the listbox vertically scrollable by the fraction of width of the longest line present in the listbox.
  587.  
  588. yview_scroll(number, what)      It is used to make the listbox vertically scrollable by the number of characters specified.
  589. """
  590.  
  591. spin = Spinbox(root, from_= 0, to = 25)  
  592. spin.pack()  
  593.  
  594. """
  595.  
  596. """
  597.  
  598. menubar=Menu(root)
  599. filemenu=Menu(menubar, tearoff=
  600. filemenu.add_command(label="New", command=donothing)
  601. filemenu.add_command(label="Open", command=donothing)
  602. filemenu.add_command(label="Save", command=donothing)
  603. filemenu.add_separator()
  604. filemenu.add_command(label="Exit", command=root.quit)
  605. menubar.add_cascade(label="File", menu=filemenu)
  606.  
  607. helpmenu=Menu(menubar, tearoff=
  608. helpmenu.add_command(label="Help Index", command=donothing)
  609. helpmenu.add_command(label="About...", command=donothing)
  610. menubar.add_cascade(label="Help", menu=helpmenu)
  611.  
  612. root.config(menu=menubar)
  613.  
  614. img_types=(("png files","*.png"),("jpeg files","*.jpg"),("all files","*.*"))
  615. filename=tkFileDialog.askopenfilename(initialdir="/",title="Select file",filetypes=img_types)
  616.  
  617. tkFileDialog.asksaveasfilename(initialdir="/",title="Select file",filetypes=img_types)
  618.  
  619. menubutton=Menubutton(root, text="File Type", relief=FLAT)  
  620.  
  621. menubutton.grid()  
  622.  
  623. menubutton.menu=Menu(menubutton)  
  624.  
  625. menubutton["menu"]=menubutton.menu  
  626.  
  627. menubutton.menu.add_checkbutton(label="Hindi", variable=IntVar())  
  628.  
  629. menubutton.menu.add_checkbutton(label="English", variable=IntVar())  
  630.  
  631. menubutton.pack()  
  632.  
  633. root.mainloop()
  634.  
  635. """
  636. activebackground        The background color of the widget when the widget is under focus.
  637.  
  638. activeforeground        The font color of the widget text when the widget is under focus.
  639.  
  640. anchor                  It specifies the exact position of the widget content when the widget is assigned more space than needed.
  641.  
  642. bg                      It specifies the background color of the widget.
  643.  
  644. bitmap                  It is set to the graphical content which is to be displayed to the widget.
  645.  
  646. bd                      It represents the size of the border. The default value is pixels.
  647.  
  648. cursor                  The mouse pointer will be changed to the cursor type specified when the widget is under the focus. The possible value of the cursor type is arrow, or dot etc.
  649.  
  650. direction               It direction can be specified so that menu can be displayed to the specified direction of the button. Use LEFT, RIGHT, or ABOVE to place the widget accordingly.
  651.  
  652. disabledforeground      The text color of the widget when the widget is disabled.
  653.  
  654. fg                      The normal foreground color of the widget.
  655.  
  656. height                  The vertical dimension of the Menubutton. It is specified as the number of lines.
  657.  
  658. highlightcolor          The highlight color shown to the widget under focus.
  659.  
  660. image                   The image displayed on the widget.
  661.  
  662. justify                 This specified the exact position of the text under the widget when the text is unable to fill the width of the widget. We can use the LEFT for the left justification, RIGHT for the right justification, CENTER for the centre justification.
  663.  
  664. menu                    It represents the menu specified with the Menubutton.
  665.  
  666. padx                    The horizontal padding of the widget.
  667.  
  668. pady                    The vertical padding of the widget.
  669.  
  670. relief                  This option specifies the type of the border. The default value is RAISED.
  671.  
  672. state                   The normal state of the Mousebutton is enabled. We can set it to DISABLED to make it unresponsive.
  673.  
  674. text                    The text shown with the widget.
  675.  
  676. textvariable            We can set the control variable of string type to the text variable so that we can control the text of the widget at runtime.
  677.  
  678. underline               The text of the widget is not underlined by default but we can set this option to make the text of the widget underlined.
  679.  
  680. width                   It represents the width of the widget in characters. The default value is wraplength    We can break the text of the widget in the number of lines so that the text contains the number of lines not greater than the specified value.
  681. """
  682.  
  683. sb=Scrollbar(root)  
  684. sb.pack(side=RIGHT, fill=Y)  
  685.  
  686. mylist=Listbox(root, yscrollcommand=sb.set)  
  687.  
  688. for line in range(:  
  689.    mylist.insert(END, "Number " + str(line))  
  690.  
  691. mylist.pack(side=LEFT)  
  692. sb.config(command=mylist.yview)  
  693.  
  694. """
  695. activebackground        The background color of the widget when it has the focus.
  696.  
  697. bg                      The background color of the widget.
  698.  
  699. bd                      The border width of the widget.
  700.  
  701. command                 It can be set to the procedure associated with the list which can be called each time when the scrollbar is moved.
  702.  
  703. cursor                  The mouse pointer is changed to the cursor type set to this option which can be an arrow, dot, etc.
  704.  
  705. elementborderwidth      It represents the border width around the arrow heads and slider. The default value is -
  706.  
  707. Highlightbackground     The focus highlighcolor when the widget doesn't have the focus.
  708.  
  709. highlighcolor           The focus highlighcolor when the widget has the focus.
  710.  
  711. highlightthickness      It represents the thickness of the focus highlight.
  712.  
  713. jump                    It is used to control the behavior of the scroll jump. If it set to  then the callback is called when the user releases the mouse button.
  714.  
  715. orient                  It can be set to HORIZONTAL or VERTICAL depending upon the orientation of the scrollbar.
  716.  
  717. repeatdelay             This option tells the duration up to which the button is to be pressed before the slider starts moving in that direction repeatedly. The default is ms.
  718.  
  719. repeatinterval          The default value of the repeat interval is
  720.  
  721. takefocus               We can tab the focus through this widget by default. We can set this option to if we don't want this behavior.
  722.  
  723. troughcolor             It represents the color of the trough.
  724.  
  725. width                   It represents the width of the scrollbar.
  726.  
  727. ###
  728.  
  729. get()                   It returns the two numbers a and b which represents the current position of the scrollbar.
  730.  
  731. set(first, last)        It is used to connect the scrollbar to the other widget w. The yscrollcommand or xscrollcommand of the other widget to this method.
  732.  
  733. """
  734.  
  735. def selection():  
  736.   selection = "You selected the option " + str(radio.get())  
  737.   label.config(text = selection)  
  738.  
  739. top = Tk()  
  740. top.geometry("300x150")  
  741. radio = IntVar()  
  742. lbl = Label(text = "Favourite programming language:")  
  743. lbl.pack()  
  744. R1 = Radiobutton(top, text="A", variable=radio, value=1,  
  745.                  command=selection)  
  746. R1.pack( anchor = W )  
  747.  
  748. R2 = Radiobutton(top, text="B", variable=radio, value=2,  
  749.                  command=selection)  
  750. R2.pack( anchor = W )  
  751.  
  752. R3 = Radiobutton(top, text="C", variable=radio, value=3,  
  753.                  command=selection)  
  754. R3.pack( anchor = W)  
  755.  
  756. label = Label(top)  
  757. label.pack()
  758.  
  759. """
  760. activebackground        The background color of the widget when it has the focus.
  761.  
  762. activeforeground        The font color of the widget text when it has the focus.
  763.  
  764. anchor                  It represents the exact position of the text within the widget if the widget contains more space than the requirement of the text. The default value is CENTER.
  765.  
  766. bg                      The background color of the widget.
  767.  
  768. bitmap                  It is used to display the graphics on the widget. It can be set to any graphical or image object.
  769.  
  770. borderwidth             It represents the size of the border.
  771.  
  772. command                 This option is set to the procedure which must be called every-time when the state of the radiobutton is changed.
  773.  
  774. cursor                  The mouse pointer is changed to the specified cursor type. It can be set to the arrow, dot, etc.
  775.  
  776. font                    It represents the font type of the widget text.
  777.  
  778. fg                      The normal foreground color of the widget text.
  779.  
  780. height                  The vertical dimension of the widget. It is specified as the number of lines (not pixel).
  781.  
  782. highlightcolor          It represents the color of the focus highlight when the widget has the focus.
  783.  
  784. highlightbackground     The color of the focus highlight when the widget is not having the focus.
  785.  
  786. image                   It can be set to an image object if we want to display an image on the radiobutton instead the text.
  787.  
  788. justify                 It represents the justification of the multi-line text. It can be set to CENTER(default), LEFT, or RIGHT.
  789.  
  790. padx                    The horizontal padding of the widget.
  791.  
  792. pady                    The vertical padding of the widget.
  793.  
  794. relief                  The type of the border. The default value is FLAT.
  795.  
  796. selectcolor             The color of the radio button when it is selected.
  797.  
  798. selectimage             The image to be displayed on the radiobutton when it is selected.
  799.  
  800. state                   It represents the state of the radio button. The default state of the Radiobutton is NORMAL. However, we can set this to DISABLED to make the radiobutton unresponsive.
  801.  
  802. text                    The text to be displayed on the radiobutton.
  803.  
  804. textvariable            It is of String type that represents the text displayed by the widget.
  805.  
  806. underline               The default value of this option is - however, we can set this option to the number of character which is to be underlined.
  807.  
  808. value                   The value of each radiobutton is assigned to the control variable when it is turned on by the user.
  809.  
  810. variable                It is the control variable which is used to keep track of the user's choices. It is shared among all the radiobuttons.
  811.  
  812. width                   The horizontal dimension of the widget. It is represented as the number of characters.
  813.  
  814. wraplength              We can wrap the text to the number of lines by setting this option to the desired number so that each line contains only that number of characters.
  815.  
  816. ###
  817.  
  818. deselect()  It is used to turn of the radiobutton.
  819.  
  820. flash()     It is used to flash the radiobutton between its active and normal colors few times.
  821.  
  822. invoke()    It is used to call any procedure associated when the state of a Radiobutton is changed.
  823.  
  824. select()    It is used to select the radiobutton. )  
  825. """
  826. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement