에 대한 Tkinter를 파이썬에서 텍스트 상자의 폭을 조정 I cloumn에 대한 다음과 같은 코드가 내 파이썬 프로그램임의의 숫자
def __init__(self):
Frame.__init__(self)
self.function = {0:self.bubble, 1:self.insertion, 2:self.selelction}
self.master.title("Sorting")
self.master.rowconfigure(5, weight=1)
self.master.columnconfigure(5, weight=1)
self.grid(sticky=W+E+N+S)
에 그리고 내가 가진 것처럼이 코드를 사용하여 저장하는 임의의 숫자에 대한 텍스트 상자 행 모든 숫자에 대해 다른 텍스트 상자.
def gen(self):
self.nums = [random.randint(0, 100) for x in range(10)]
for num in self.nums:
i=iter(self.nums)
item1=i.next()
item2=i.next()
item3=i.next()
item4=i.next()
item5=i.next()
item6=i.next()
item7=i.next()
item8=i.next()
item9=i.next()
item10=i.next()
#num = ''.join('%4i' % num for num in self.nums)
self.text1 = Text(self,width=2, height=1)
self.text1.grid(row =3,column=0,sticky = W+E+N+S)
self.text1.insert(END,item1)
self.text2 = Text(self,width=2, height=1)
self.text2.grid(row =3,column=1,sticky = W+E+N+S)
self.text2.insert(END,item2)
self.text3 = Text(self,width=2, height=1)
self.text3.grid(row =3,column=2,sticky = W+E+N+S)
self.text3.insert(END,item3)
self.text4 = Text(self,width=2, height=1)
self.text4.grid(row =3,column=3,sticky = W+E+N+S)
self.text4.insert(END,item4)
self.text5 = Text(self,width=2, height=1)
self.text5.grid(row =3,column=4,sticky = W+E+N+S)
self.text5.insert(END,item5)
self.text6 = Text(self,width=2, height=1)
self.text6.grid(row =3,column=5,sticky = W+E+N+S)
self.text6.insert(END,item6)
self.text7 = Text(self,width=2, height=1)
self.text7.grid(row =3,column=6,sticky = W+E+N+S)
self.text7.insert(END,item7)
self.text8 = Text(self,width=2, height=1)
self.text8.grid(row =3,column=7,sticky = W+E+N+S)
self.text8.insert(END,item8)
self.text9 = Text(self,width=2, height=1)
self.text9.grid(row =3,column=8,sticky = W+E+N+S)
self.text9.insert(END,item9)
self.text10 = Text(self,width=2, height=1)
self.text10.grid(row =3,column=9,sticky = W+E+N+S)
self.text10.insert(END,item10)
그러나 이와 같은 결과는 아래와 같습니다. 어떻게하면이 문제를 해결할 수 있을까요?
모든 숫자에 대한 텍스트 상자가 다소 과장된 것 같습니다. 다양한 텍스트 범위에 다른 색상을 적용 할 수 있다는 것을 알고 있습니까? 여러 위젯을 사용하는 유일한 이유는 색상을 지정하기위한 것이므로 여러 라벨 또는 단일 텍스트 위젯을 사용하십시오. –
수정 방법은 묻지 만 "수정"의 의미는 정의하지 마십시오. 각 셀이 똑같이 확장되기를 원하십니까? 두 문자 모두 너비가 넓습니까? 아니면 "축소되도록"변형해야합니까? –
나중에 각 텍스트 상자가 똑같이 확장되기를 원합니다. 마지막 숫자가 표시됩니다. 처음 3 개가 그처럼 보이기를 원합니다. –