0

+ +_+ + +_+ + +_+ + +_+ + +_+ + +_+ ++

** どうでも!** この質問は答えられています! そのルートの蜜ろうの代わりに、これが一番下に必要でした...

うん。底でした。ちょっとしたコードのクリーニングが必要だっただけです:)...気にしないでください。とにかくありがとう!

#omit root
app = App()
app.mainloop()

+ +_+ + +_+ + +_+ + +_+ + +_+ + +_+ + ++

この 2 番目のウィンドウを取り除くために 2 時間懸命に努力しました。フォルダ名を尋ねるポップアップを実装した後、プログラムの実行時に突然 2 つのウィンドウが開いてしまいました。私はただ1つ欲しいだけです、それは本当にかなり悪化しています. このプログラムで、4 つのボタンを備えた 1 つのウィンドウを開き、その上にタイトルを表示したいと考えています。ボタンの 1 つが入力を要求し、その後消えます。誰かが 1 つのウィンドウに戻るのを手伝ってくれませんか? ありがとうございました。乱雑なコードで申し訳ありません。このスタイルのスクリプトは初めてです。

#!/usr/bin/python
            #from Tkinter import *
            import Tkinter as tk

            import os
            import tkFileDialog

            class App(tk.Tk):
            #class App:

                #def __init__(self, master):
                def __init__(self):
                tk.Tk.__init__(self)


                frame = tk.Frame(self)
                frame.pack()

                self.button = tk.Button(frame, text="leave", fg="red", command=frame.quit)
                self.button.pack(side=tk.LEFT)

                self.fetch = tk.Button(frame,text="Choose Folder for Pictures",fg="salmon",command=self.choose)
                self.fetch.pack(side=tk.LEFT)

                self.fetch = tk.Button(frame,text="Name folder on site (public)",command=self.on_click)
                self.fetch.pack(side=tk.LEFT)

                self.hi_there = tk.Button(frame, text="Create code for images", fg="brown", command=self.generate)
                self.hi_there.pack(side=tk.LEFT)
                #oroville dam is the highest in the country
                w = tk.Label(text="MSP Art File Fetcher")
                w.pack()
             # Toplevel window

                top = self.top = tk.Toplevel(self)
                myLabel = tk.Label(top, text='Name of image directory:')
                myLabel.pack()

                self.myEntryBox = tk.Entry(top)
                self.myEntryBox.pack()

                mySubmitButton = tk.Button(top, text='Done', command=self.submit_name)
                mySubmitButton.pack()

                top.protocol("WM_DELETE_WINDOW", self.save_top)

                top.withdraw()



                def save_top(self):
                self.top.withdraw()


                def choose(self):
                self.foldername=tkFileDialog.askdirectory()
                print self.foldername


                def name(self):
                print self.foldername

                def generate(self): 
                print self.foldername  
                    self.path=self.foldername  # failing, works
                self.dirlist=os.listdir(self.path)
                yoz = file('demcode.txt','wt')#totally works
                f=open('demcode.txt', 'r+')
                f.write(self.foldername)
                f.write('\ndo not be a crack addic\n')
                f.write('\n')
                print self.dirlist
                print self.dirlist[0]
                self.y=len(self.dirlist)
                print self.y
                for x in range(0,self.y): #works great
                #for x in range(0,4):#self.y: #failing
                    print 'We\'re on image %d' % (x)
                #print in self.dirlist
                f.write('\n'.join(self.dirlist[0]))#returns a vertical word!?
                f.write('\n')   
                f.write(self.dirlist[0])
                f.write('\n')
                f.write('\n')
                f.write('\n')   
                f.write(', '.join(self.dirlist))#CAUTION, will write over existing data

                def say_hi(self):
                print "don't be a crack addic"

                def submit_name(self):
                if self.myEntryBox.get() != "":
                    self.username = self.myEntryBox.get()
                    self.myEntryBox.delete(0, 'end')
                    self.top.withdraw()

                def on_click(self):
                self.top.deiconify()
            """
                def show_name(self):
                self.mainText.delete('1.0', 'end')
                self.mainText.insert('end', 'Welcome ' + self.username + '!')
            """
            root = tk.Tk()

            app = App()

            root.mainloop()
            """
            """
            achieve this format of html.  python program will loop every file in the directory, placing the name of the file in the set path (asked directory name), and write the approiate code for lightbox
            """
            <h1>MSP (Acorns) Gallery</h1>
            #http://www.mspart.com/lightbox.html
            <div id="page">
            <div id="images">
            <ul class="gallery">
              <a href="images/Pastels/alpha_farm.jpg" rel="lightbox"> </a>
              <li><a href="images/Pastels/alpha_farm.jpg" rel="lightbox"><img src="images/Pastels/alpha_farm.jpg" alt="description"></a></li>
              <a href="images/Pastels/_day_island.jpg" rel="lightbox"> </a>
              <li><a href="images/Pastels/_day_island.jpg" rel="lightbox"><img src="images/Pastels/_day_island.jpg" alt="description"></a>
            </li></ul>
            </div>
            </div>
4

1 に答える 1