1

リスト ボックスに入力する 3 つのリストがあります。私が知りたいのは、名前、日付、情報がすべて一列に並ぶようにフレーズをフォーマットする方法です。+ を使用して 3 つの 3 つの部分をすべて結合しようとしましたが、名前が大きくなったり小さくなったりするとすぐに、他のすべてが外れてしまいます。

class showTask:
    def __init__(self):
        self.showWindow = Tk()
        self.showWindow.configure(background = "black")
        self.showWindow.geometry("750x750")
        self.showWindow.resizable(width = False, height = False)
        self.showWindow.title("Show All Tasks")
        self.listBox = Listbox(self.showWindow,height = 10, width = 80)
        self.listBox.place(relx = 0.02, rely = 0.2)
        self.showButton = Button(self.showWindow, height = 5, width = 20, text="Search for Task",highlightbackground="black",font=("Helvetica",10,"bold"),command=lambda:self.showFuntion())
        self.showButton.place(relx = 0.01,rely = 0.05)



    def showFuntion(self):
        self.listBox.delete(0,END)
        self.file = open("dataFile.txt", "r+")
        fileData = self.file.readlines()
        self.file.close()
        counter = 1
        self.name = []
        self.date = []
        self.details = []
        lengthOfFile = len(fileData)
        for i in range (lengthOfFile):
            split = fileData[i].split("\n")
            while counter == 1:
                self.name.append(split)
                break
            while counter == 2:
                self.date.append(split)
                break
            while counter == 3:
                self.details.append(split)
                break
            counter = counter +1
            if counter > 3:
                 counter = 1

        for x in range(len(self.name)):
            line = self.name[x][0]+"|"+self.date[x][0]+"|"+self.details[x][0]
            self.listBox.insert(END,line)
4

1 に答える 1

0

スクロールバー ウィジェットを使用できます。

self.scrollbar=Scrollbar(self.showWindow, orient=HORIZONTAL)
self.scrollbar.pack(side=BOTTOM, fill=X)

self.listBox= Listbox(self.showWindow, height=10, width=80, xscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.listBox.xview)

詳細については、http: //effbot.org/tkinterbook/scrollbar.htmを参照してください。

于 2013-05-24T07:16:32.893 に答える