+ + _ + + + _ + + + _ + + + _ + + + _ + + + _ + ++두 창, 날 괴물
** 신경 쓰이지 마라! **이 질문에 답합니다! 그것은 그 뿌리 beezwax 대신에 바닥에 이것을 필요로했습니다 ...
예. 그것은 바닥이었다. 그것은 단지 약간의 코드 정리가 필요했습니다.) .... 신경 쓰지 마라. 어쨌든 고마워요!
#omit root
app = App()
app.mainloop()
+ + _ + + + _ + + + _ + + + _ + + + _ + + + + _ + ++
두 번째 창을 없애기 위해 두 시간 동안 열심히 노력했습니다. 폴더 이름을 묻기 위해 팝업을 구현 한 후 프로그램이 실행될 때 갑자기 두 개의 창이 열렸습니다. 나는 단지 하나를 원한다. 그것은 정말로 심하게 악화되고있다. 이 프로그램이 4 개의 버튼으로 하나의 창을 열고 그 위에 제목이 있어야합니다. 단추 중 하나가 입력을 요청한 다음 사라집니다. 누군가 내가 한 창으로 돌아갈 수 있도록 도와 줄 수 있습니까? 고맙습니다. 지저분한 코드에 사과드립니다.이 스타일의 첫 번째 스크립트입니다. 당신의 app
클래스에서
#!/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>
솔루션을 찾은 경우 대답으로 게시하고 [승인 된 것으로 표시] (http://meta.stackexchange.com/questions/5234)해야합니다. –
예, 방금 프로필을 만들었습니다. 오버플로에서 이상한 8 시간 블록이 나에게 답을 추가하거나 해결 된 것으로 표시하는 것을 막습니다. –