पायथन के साथ व्यक्तिगत उपयोग के लिए एक छोटा सा एप्लीकेशन बनाना और सोचा कि मैं टिंकर का उपयोग करके थोड़ा सा जीयूआई प्रोग्रामिंग के साथ अपना हाथ आजमाऊंगा।जीईआई लेआउट का उपयोग कर ग्रिड ज्यामिति प्रबंधक
आवेदन संदेह:: - स्क्रीनशॉट में ए, बी और सी - है
कैसे मुझे यकीन है कि तीन LableFrames कर सकते हैं यह जीयूआई मैं अब तक बना लिया है एक ही चौड़ाई? (या इसके बजाए, चौड़ाई के तीनों के बराबर चौड़ाई है? उदाहरण के लिए, स्क्रीनशॉट में, ए सबसे व्यापक है और मैं बी और सी को लाइन डी तक भी चौड़ा होना चाहता हूं)।
-(यह पर्याप्त है अगर मैं सुनिश्चित कर सकते हैं कि चौड़ाई जब मैं यह कोड एक ही हैं, पहली बार दौर वे क्रम पर बदलने की जरूरत नहीं है यह गतिशील रूप से गणना करने के लिए नहीं है।।)
टी ग्रिड ज्यामिति प्रबंधक संदेह:
आप फ्रेम का उपयोग करते हैं, ग्रिड (पंक्ति, कॉलम) विशिष्ट फ्रेम के केवल आकार करने के लिए है या यह (फार्म के आकार के आधार पर की जाती है जड़ खिड़की)?
ग्रिड में निर्धारित कॉलम का आकार कैसा है?
- मुझे पूरी तरह से समझ में नहीं आया है कि एक ग्रिड के भीतर 'वजन' क्या करता है। इसका इस्तेमाल कब किया जाना चाहिए?
अजगर जीयूआई कोड:
import Tkinter
if __name__ == '__main__':
form = Tkinter.Tk()
getFld = Tkinter.IntVar()
form.wm_title('File Parser')
stepOne = Tkinter.LabelFrame(form, text=" 1. Enter File Details: ")
stepOne.grid(row=0, columnspan=7, sticky='W', \
padx=5, pady=5, ipadx=5, ipady=5)
helpLf = Tkinter.LabelFrame(form, text=" Quick Help ")
helpLf.grid(row=0, column=9, columnspan=2, rowspan=8, \
sticky='NS', padx=5, pady=5)
helpLbl = Tkinter.Label(helpLf, text="Help will come - ask for it.")
helpLbl.grid(row=0)
stepTwo = Tkinter.LabelFrame(form, text=" 2. Enter Table Details: ")
stepTwo.grid(row=2, columnspan=7, sticky='W', \
padx=5, pady=5, ipadx=5, ipady=5)
stepThree = Tkinter.LabelFrame(form, text=" 3. Configure: ")
stepThree.grid(row=3, columnspan=7, sticky='W', \
padx=5, pady=5, ipadx=5, ipady=5)
inFileLbl = Tkinter.Label(stepOne, text="Select the File:")
inFileLbl.grid(row=0, column=0, sticky='E', padx=5, pady=2)
inFileTxt = Tkinter.Entry(stepOne)
inFileTxt.grid(row=0, column=1, columnspan=7, sticky="WE", pady=3)
inFileBtn = Tkinter.Button(stepOne, text="Browse ...")
inFileBtn.grid(row=0, column=8, sticky='W', padx=5, pady=2)
outFileLbl = Tkinter.Label(stepOne, text="Save File to:")
outFileLbl.grid(row=1, column=0, sticky='E', padx=5, pady=2)
outFileTxt = Tkinter.Entry(stepOne)
outFileTxt.grid(row=1, column=1, columnspan=7, sticky="WE", pady=2)
outFileBtn = Tkinter.Button(stepOne, text="Browse ...")
outFileBtn.grid(row=1, column=8, sticky='W', padx=5, pady=2)
inEncLbl = Tkinter.Label(stepOne, text="Input File Encoding:")
inEncLbl.grid(row=2, column=0, sticky='E', padx=5, pady=2)
inEncTxt = Tkinter.Entry(stepOne)
inEncTxt.grid(row=2, column=1, sticky='E', pady=2)
outEncLbl = Tkinter.Label(stepOne, text="Output File Encoding:")
outEncLbl.grid(row=2, column=5, padx=5, pady=2)
outEncTxt = Tkinter.Entry(stepOne)
outEncTxt.grid(row=2, column=7, pady=2)
outTblLbl = Tkinter.Label(stepTwo, \
text="Enter the name of the table to be used in the statements:")
outTblLbl.grid(row=3, column=0, sticky='W', padx=5, pady=2)
outTblTxt = Tkinter.Entry(stepTwo)
outTblTxt.grid(row=3, column=1, columnspan=3, pady=2, sticky='WE')
fldLbl = Tkinter.Label(stepTwo, \
text="Enter the field (column) names of the table:")
fldLbl.grid(row=4, column=0, padx=5, pady=2, sticky='W')
getFldChk = Tkinter.Checkbutton(stepTwo, \
text="Get fields automatically from input file",\
onvalue=1, offvalue=0)
getFldChk.grid(row=4, column=1, columnspan=3, pady=2, sticky='WE')
fldRowTxt = Tkinter.Entry(stepTwo)
fldRowTxt.grid(row=5, columnspan=5, padx=5, pady=2, sticky='WE')
transChk = Tkinter.Checkbutton(stepThree, \
text="Enable Transaction", onvalue=1, offvalue=0)
transChk.grid(row=6, sticky='W', padx=5, pady=2)
transRwLbl = Tkinter.Label(stepThree, \
text=" => Specify number of rows per transaction:")
transRwLbl.grid(row=6, column=2, columnspan=2, \
sticky='W', padx=5, pady=2)
transRwTxt = Tkinter.Entry(stepThree)
transRwTxt.grid(row=6, column=4, sticky='WE')
form.mainloop()
(नोट: अजगर 2.4.3 के लिए)
बहुत अच्छा जवाब, वॉन। –