Home > other >  Novice for help: tkinter after interface jump, checkButton unable to get variable
Novice for help: tkinter after interface jump, checkButton unable to get variable

Time:12-01

When using python tkinter in interface design, click on the button to return the result of the text box, and the result of the select button;

But after the new window, select the value of the button can't real return, and the text frame's demerit can return to normal, have a great god can help have a look at my new, thank you,

Or how can complete menu, new function,


The code is as follows:
 

The import tkinter as tk
The from tkinter import TTK
The from tkinter import Menu

#======================================================================
Class WINDOWS1 (tk) Frame) :


Def __init__ (self, master=None) :
The self. The master=master
Tk. Frame. __init__ (self, master)
The self. The grid ()
The self. The button ()

Def fun_C (self) :
Print (self) chVarDis1) get ())
Print (self. Number. The get ())

Def button (self) :
Self. ChVarDis1=tk. IntVar ()
Self. Cheak1=tk. Checkbutton (self, variable=self. ChVarDis1)
Self. Cheak1. The grid (row=0, the column=1, sticky=tk. W, padx=5)
#
C=tk. IntVar ()
Self. Number=TTK. Entry (self, width=5, textvariable=c)
Self. Number. The grid (row=0, the column=0)
#
Self. For the=TTK. Button (self, text='ok', the command=self. Fun_C)
The self, for the grid (row=0, the column=2)

The class MenuBar (WINDOWS1) :

Def __init__ (self, master) :
Super (MenuBar, self) __init__ (master)
The self. The master=master
The self. The menubar ()

Def menubar (self) :
"' # the create menu bar" '
The self. The menu=menu (self)
Win. Config (menu=self. Menu)
Self. File_menu=Menu (self. Menu, tearoff=0) # Menu
Self. Menu. Add_cascade (label='File' menu.=the self file_menu)
Self. File_menu. Add_command (label='New', the command=self new_file)

Def new_file (self) :
Win2=tk. Tk ()
Win2. Geometry (' 180 x70)
WINDOWS1 (master=win2)

#======================================================================
If __name__=="__main__ ':
Win=tk. Tk ()
Win. Geometry (' 180 x70)
# WINDOWS1 (master=win)
The MenuBar (master=win)
Win the mainloop ()

  • Related