标题边界Tkinter - 没有出现

时间:2016-01-30 01:13:40

标签: python user-interface tkinter

我有这个代码,但这只是一个很长的系统代码的一部分。问题是,我试图创建一个标题边框,但它没有出现。我不知道这是什么错误。

from Tkinter import *
def onclick():
    pass

import tkMessageBox


root = Tk()

root.title("Pantai Hospital")
root.geometry("200x200")

Label(root, text = "Welcome to Pantai Hospital!").grid()

#the problem starts here
f1 = Frame(root, width = 300, height = 110)
f2 = Frame(f1, relief = GROOVE, borderwidth = 2) 


l9 = Label(f2, text = "Choose your specialist:")
l9.pack(pady = 10)

specialistchoose = IntVar()
r1 = Radiobutton (f2, text = "Cardiology", variable = specialistchoose, value = 1)
r1.grid(row = 1, column = 0 ) 
r2 = Radiobutton (f2, text = "Gastroenterology", variable = specialistchoose, value = 2)
r2.grid(row = 1, column = 1) 
r3 = Radiobutton (f2, text = "Dermatology", variable = specialistchoose, value = 3)
r3.grid (row = 1, column = 2)
r4 = Radiobutton (f2, text = "Psychiatry", variable = specialistchoose, value = 4)
r4.grid (row = 3, column = 0)
r5 = Radiobutton (f2, text = "Dentist", variable = specialistchoose, value = 5)
r5.grid(row = 3, column = 1)
f2.place(relx = 0.01, rely = 0.125, anchor = NW)
Label(f1, text = "Specialist:").place(relx = .06, rely = 0.125, anchor = W)
f1.pack() 
root.mainloop() 

有没有人知道如何fx这个?谢谢你:))

1 个答案:

答案 0 :(得分:1)

问题是因为您混合了var someKeyName = 'static'; var arrCategory = [{ 'static': [{ 'theme1': [{ 'name':'vari-1', 'picture':'./images/static/theme-1/vari-1/1.jpg', 'price':'10000' }] }, { 'theme2': [{ 'name':'vari-1', 'picture':'./images/static/theme-2/vari-1/1.jpg', 'price':'10000' }] }] }]; arrCategory[0][someKeyName].forEach(function(k,d){ //console.log(k); var thisKey = Object.keys(k)[0]; // ['theme1'], then ['theme2'] var subKeys = Object.keys(k[thisKey][0]); // ["name", "picture", "price"] subKeys.forEach(function(key){ console.log(k[thisKey][0][key]); // logged to console because the alert loop was annoying }); });grid()并且收到了错误消息。

请勿在同一pack()(或grid())中使用pack()Frame。但您仍然可以在一个Window中使用grid(),在另一个Frame中使用pack()(另一帧甚至可以在第一帧内)。

所以再试一次。

编辑: FrameLabelFrameborder。您可以使用它代替titleFrame

Label

enter image description here