[英]i wanna make gui for some function but it's not like what i want i am using python 2.7 and it's Tkinter?
i want to put that second entry in down to drop down menu help me to fix this? 我想将第二个条目放到下拉菜单中,以帮助我解决此问题? i tried with place and pack but i don't know where i am doing mistake help me to fix this you can specify the function and how to use it like width and height position ?
我尝试放置和打包,但是我不知道我在哪里做错了,请帮助我解决此问题。您可以指定功能以及如何使用它,例如宽度和高度位置?
import Tkinter as Tk
from Tkinter import *
network = Tk(className ="Network")
network.geometry('1000x600') # Size 200, 200
network.resizable(width=False,height=False)
svalue = StringVar() # defines the widget state as string
w = Entry(network,width=80,textvariable=svalue) # adds a textarea widget
w.pack(side=TOP and LEFT)
w.place(x=3,y=3)
button1 = Button(network,text="Press Me")
button1.pack()
# Add a grid
mainframe = Frame(network)
mainframe.grid(column=0,row=0, sticky=(N,W,E,S))
mainframe.columnconfigure(0, weight = 1)
mainframe.rowconfigure(0, weight = 1)
mainframe.place(x=10,y=30)
# Create a Tkinter variable
tkvar = StringVar(network)
# Dictionary with options
choices = { 'IP scanning','openport scanning','','Finding Emails based on domainname','OS footprinting'}
tkvar.set('IP scanning') # set the default option
popupMenu = OptionMenu(mainframe, tkvar, *choices)
button2=Button(mainframe, text="Choose any of them").grid(row = 1, column = 1)
popupMenu.grid(row = 2, column =1)
# on change dropdown value
def change_dropdown(*args):
print(tkvar.get())
# link function to change dropdown
tkvar.trace('w', change_dropdown)
T = Text(network, height=20,width=60)
T.grid(row=3,column=0)
T.pack()
T.insert(END,"Just a text widget\nin two lines\n")
network.mainloop()
You can manually place the text area T
under the pop up box by using the place
function. 您可以使用
place
功能将文本区域T
手动放置在弹出框下。 You give the x and y co-ordinates a value to place it where you want on the GUI. 您可以给x和y坐标赋予一个值,以将其放置在GUI上所需的位置。
T.place(y = 85)
will place it under the pop up box. T.place(y = 85)
将其放置在弹出框下面。 You can also give an x value to it. 您也可以给它一个x值。
There are a few other errors in your code too, but I hope this was what you were looking for. 您的代码中也存在其他一些错误,但是我希望这就是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.