Python3'te titizlik araştırıyorum ve ilk GUI projemi başlattım.Kılavuzlu Python3/tkinter'de 3 çerçeveli ve dinamik yerleşimli basit bir pencere nasıl oluşturulur?
- Üst çerçeve: araç çubuğu, belki arama alanı (bazı düğmeler, her zaman görünür olmasını ve tutması gerektiğini Böyle basit bir düzen oluşturmak için ızgara konumlandırma sistemi kullanmak ve 3 kare çalışıyorum pencerenin üstü ve soldan sağa doğru genişletin).
- Ana çerçeve: ağaç görünümü, bir veritabanından değerleri almayı amaçlayan (üst çerçeveye, üst çerçevenin sağına, soldan sağa doğru genişleyen ve aynı zamanda üst ve alt tarafından kalan tüm alanı almak için genişletmeli) kareler).
- Alt çerçeve: veri giriş formu, durum çubuğu ... (soldan sağa genişleyen, pencerenin alt sopa ve ana çerçeveye boşluk bırakın
ben olmalıydım. çerçeveler ve ağırlıklar ile uğraşmak ve her zaman yanlış bir şey gibi görünüyor.Eğer yeterince küçük pencereyi yeniden boyutlandırırsanız, ana çerçeve kısmen üst çerçeveyi gizler.Eğer pencereyi genişletirseniz, ana çerçeve ve ağaç görünümü tüm yolu genişletmiyor İstenildiği kadar herkes yardım edebilir mi?
Şu anki kodum şu anda elimde:
#!/usr/local/bin/python3
# encoding: utf-8
"""
docstring
"""
import sys
import os
import os.path
import csv
import re
from platform import node
from tkinter import *
from tkinter import ttk
__app_name__ = "APP NAME"
__version__ = "0.0.1"
def add_remessa():
pprint("REMESSA")
def click_btn_hoje():
print("HOJE")
root = Tk()
root.title(__app_name__+" "+__version__)
root.rowconfigure(0, weight=1)
root.columnconfigure(0, weight=1)
topframe = ttk.Frame(root, padding="3 3 12 12")
topframe.grid(column=0, row=0, sticky=(N, E, W))
topframe.columnconfigure(0, weight=1)
topframe.columnconfigure(1, weight=1)
topframe.rowconfigure(0, weight=1)
topframe.rowconfigure(0, weight=1)
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=1, sticky=(N, W, E))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
bottomframe = ttk.Frame(root, padding="3 3 12 12")
bottomframe.grid(column=0, row=2, sticky=(W, E, S))
bottomframe.columnconfigure(0, weight=1)
bottomframe.columnconfigure(1, weight=1)
bottomframe.rowconfigure(0, weight=1)
bottomframe.rowconfigure(0, weight=1)
def NovaRemessa():
print("Nova remessa!")
def EditarRemessa():
print("Editar")
def About():
print("This is a simple example of a menu")
def painelAddRemessa():
print("Mostrar painel de introdução de nova remessa")
btn_quit = ttk.Button(topframe, text="+", command=painelAddRemessa)
btn_quit.grid(row=0, column=6, sticky=E+N)
btn_quit = ttk.Button(topframe, text=" Sair ", command=exit)
btn_quit.grid(row=0, column=1, sticky=E+N)
# Data entry form
obj_num = StringVar()
destin = StringVar()
cobr = StringVar()
dias = StringVar()
vols = StringVar()
ttk.Label(bottomframe, text="Nº Objeto").grid(row=5, column=0, sticky=W+S)
text_input_obj = ttk.Entry(bottomframe,textvariable=obj_num, width=13)
text_input_obj.grid(row=6, column=0, sticky=W+S)
text_input_obj.focus_set()
ttk.Label(bottomframe, text="Destinatário").grid(row=5, column=1, columnspan=1, sticky=W+S)
text_input_dest = ttk.Entry(bottomframe, textvariable=destin, width=25)
text_input_dest.grid(row=6, column=1, sticky=W+S)
ttk.Label(bottomframe, text="Cobrança").grid(row=5, column=2, sticky=W+E+S)
text_input_cobr = ttk.Entry(bottomframe, textvariable=cobr, width=7)
text_input_cobr.grid(row=6, column=2, sticky=W+E+S)
ttk.Label(bottomframe, text="Dias").grid(row=5, column=3, sticky=W+E+S)
text_input_dias = ttk.Entry(bottomframe, textvariable=dias, width=4)
text_input_dias.grid(row=6, column=3, sticky=W+E+S)
ttk.Label(bottomframe, text="Volumes").grid(row=5, column=4, sticky=W+E+S)
text_input_vols = ttk.Entry(bottomframe, textvariable=vols, width=5)
text_input_vols.grid(row=6, column=4, sticky=W+E+S)
# Botões
btn_add = ttk.Button(bottomframe, text=" Adicionar ", command=add_remessa).grid(row=6, column=6,sticky=W+E+S)
ttk.Label(mainframe, text="Nº de remessas: XXXX").grid(row=2, column=0, columnspan=2, sticky=W)
ttk.Label(mainframe, text="Valor a cobrar: XXXXXX").grid(row=2, columnspan=2, column=2)
ttk.Label(mainframe, text="Recebido: XXXXX").grid(row=2, column=4)
ttk.Label(mainframe, text="Depositar: XXXXXXX").grid(row=2, column=6, sticky=E)
tree = ttk.Treeview(mainframe, selectmode='extended')
tree['columns'] = ('ID', 'Dias', 'Destinatário', 'Estado', 'Objeto nº', 'Cobr.', 'Chq.rec.', 'Depositar')
tree.grid(row=0, column=0, columnspan=7, sticky=N+W+E+S)
tree.column('#0', anchor=W, minwidth=0, stretch=0, width=0)
tree.column('ID', anchor=W, minwidth=30, stretch=1, width=30)
tree.column('Dias', minwidth=30, stretch=1, width=30)
tree.column('Destinatário', minwidth=100, stretch=1, width=200)
tree.column('Estado', minwidth=100, stretch=1, width=180)
tree.column('Objeto nº', minwidth=50, stretch=1, width=80)
tree.column('Cobr.', minwidth=60, stretch=1, width=60)
tree.column('Chq.rec.', minwidth=80, stretch=1, width=80)
tree.column('Depositar', anchor=E, minwidth=80, stretch=1, width=80)
tree.heading('ID', text="ID")
tree.heading('Dias', text="Dias")
tree.heading('Destinatário', text="Destinatário")
tree.heading('Estado', text="Estado")
tree.heading('Objeto nº', text="Objeto nº")
tree.heading('Cobr.', text="Cobr.")
tree.heading('Chq.rec.', text="Chq.rec.")
tree.heading('Depositar', text="Depositar")
for child in mainframe.winfo_children(): child.grid_configure(padx=1, pady=1)
mainloop()
Sorunu göstermek için bu kodun tümüne ihtiyacınız yoktur. Lütfen http://www.stackoverflow.com/help/mcve adresini ziyaret edin –
Üzgünüz! Ben şimdi çözmek için çalışıyorum sorun ile ilgili olmadığını inanıyorum kod bazı bölümlerini kaldırdık. –