我正在使用一个简单的应用程序(.exe)通过Python / PC与我的PLC通信。到目前为止,一切工作正常,我知道Tkinter将使用OS中的默认小部件(本机小部件),但应用程序(GUI)在win7 / win10上看起来有所不同。问题是窗口右边的“空白”空间很大(有6个窗口,所有问题相同,空白区域相同,大小相同)。我不确定为什么会这样。有没有办法减少或完全删除它?填充有问题吗?
我使用Python 2.7,Tkinter 8.5,Pyinstaller。您可以在link上查看图像。
from Tkinter import *
import tkFileDialog
import pandas as pd
import tkFileDialog
from PIL import ImageTk, Image
import os
from ttk import *
import xlrd
from openpyxl import load_workbook
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4, landscape
def resource_path(relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)
fname = None
excelfile = str(None)
naziv = str(None)
lokacija = str(None)
lokacija1 = str(None)
brojredova = int(0)
X = int(0)
Y = int(0)
odabrano = str(1)
odabrano1 = str(1)
rh1 = "No"
rh2 = "No"
rh3 = "No"
ch1 = "No"
ch2 = "No"
def osnovni_prozor():
window.deiconify()
def spec_paneli():
window.withdraw()
global X, Y, odabrano, odabrano1
sub2 = Toplevel(window)
sub2.title("Panels")
X = window.winfo_x()
Y = window.winfo_y()
x = X
y = Y
sub2.geometry("800x875")
sub2.geometry("+%d+%d" % (x, y))
sub2.configure(background='white')
sub2.resizable(width=False, height=False)
noteStyler = Style()
noteStyler.configure("TNotebook", borderwidth=0)
noteStyler.configure("TNotebook.Tab", background='white', foreground="black", lightcolor='red', borderwidth=0)
noteStyler.configure("TFrame", background='white', foreground='white', borderwidth=0)
s1 = Style()
s1.configure('Wild.TLabel', background='white', foreground='black')
sub2.grid_rowconfigure(0, minsize=25)
note = Notebook(sub2)
tab1 = Frame(note)
tab2 = Frame(note)
tab3 = Frame(note)
tab4 = Frame(note)
note.add(tab1, text=' General ')
note.add(tab2, text='Cable casing')
note.add(tab3, text='Reinforcement')
note.add(tab4, text=' Profiles ')
note.pack(expand=1, fill='both')
frame1 = Frame(tab1)
frame1.grid(row=0, column=0, sticky="n")
frame1.grid_rowconfigure(0, minsize=20)
lbl1 = Label(frame1, text='Panel width', style='Wild.TLabel')
lbl1.grid(column=0, row=2, padx=35, pady=8, sticky=W)
lbl2 = Label(frame1, text='Panel height', style='Wild.TLabel')
lbl2.grid(column=0, row=3, padx=35, pady=8, sticky=W)
lbl3 = Label(frame1, text='Panel thickness', style='Wild.TLabel')
lbl3.grid(column=0, row=4, padx=35, pady=8, sticky=W)
lbl4 = Label(frame1, text='Type of panel', style='Wild.TLabel')
lbl4.grid(column=0, row=5, padx=35, pady=8, sticky=W)
lbl5 = Label(frame1, text='Filling', anchor="e", style='Wild.TLabel')
lbl5.grid(column=0, row=10, padx=35, pady=8, sticky=W)
lbl6 = Label(frame1, text='Framework', anchor="e", style='Wild.TLabel')
lbl6.grid(column=0, row=11, padx=35, pady=8, sticky=W)
lbl7 = Label(frame1, text='Opening', style='Wild.TLabel')
lbl7.grid(column=0, row=14, padx=35, pady=8, sticky=W)
lbl8 = Label(frame1, text='Count', style='Wild.TLabel')
lbl8.grid(column=0, row=13, padx=35, pady=8, sticky=W)
lbl10 = Label(frame1, text='Rivets', style='Wild.TLabel')
lbl10.grid(column=0, row=12, padx=35, pady=8, sticky=W)
lbl11 = Label(frame1, text='Sheet 1 material', style='Wild.TLabel')
lbl11.grid(column=0, row=6, padx=35, pady=8, sticky=W)
lbl12 = Label(frame1, text='Sheet 2 material', style='Wild.TLabel')
lbl12.grid(column=0, row=7, padx=35, pady=8, sticky=W)
lbl13 = Label(frame1, text='Sheet 1 color', style='Wild.TLabel')
lbl13.grid(column=0, row=8, padx=35, pady=8, sticky=W)
lbl14 = Label(frame1, text='Sheet 2 color', style='Wild.TLabel')
lbl14.grid(column=0, row=9, padx=35, pady=8, sticky=W)
txt1 = Entry(frame1, width=10, justify='center')
txt1.grid(column=1, row=2)
txt1.focus()
txt2 = Entry(frame1, width=10, justify='center')
txt2.grid(column=1, row=3)
combo1 = Combobox(frame1, state="readonly")
combo1['values'] = ("42mm", "62mm", "82mm")
combo1.current(0) # set the selected item
combo1.grid(column=1, row=4)
combo2 = Combobox(frame1, state="readonly")
combo2['values'] = ("Wall panel", "Ceiling panel", "Special")
combo2.current(0) # set the selected item
combo2.grid(column=1, row=5)
combo3 = Combobox(frame1, state="readonly")
combo3['values'] = ("Rockwool", "ALU honeycomb", "Other", "None")
combo3.current(0) # set the selected item
combo3.grid(column=1, row=10)
combo4 = Combobox(frame1, state="readonly")
combo4['values'] = ("Aluminum", "Galvanised steel", "Other", "None")
combo4.current(0) # set the selected item
combo4.grid(column=1, row=11)
txt3 = Entry(frame1, width=10, justify='center')
txt3.grid(column=1, row=13)
txt4 = Entry(frame1, width=10, justify='center')
txt4.grid(column=1, row=8)
txt5 = Entry(frame1, width=10, justify='center')
txt5.grid(column=1, row=9)
combo6 = Combobox(frame1, state="readonly")
combo6['values'] = ("None", "1S Bottom", "1S Top", "Both")
combo6.current(0) # set the selected item
combo6.grid(column=1, row=12)
combo7 = Combobox(frame1, state="readonly")
combo7['values'] = ("Aluminum", "Galvanised steel", "Stainless steel")
combo7.current(0) # set the selected item
combo7.grid(column=1, row=6)
combo8 = Combobox(frame1, state="readonly")
combo8['values'] = ("Aluminum", "Galvanised steel", "Stainless steel", "None")
combo8.current(0) # set the selected item
combo8.grid(column=1, row=7)
frame3 = Frame(frame1)
frame3.grid(row=15, column=0, sticky="n", columnspan=2)
frame3.grid_columnconfigure(0, minsize=20)
lbl31 = Label(frame3, text='R X1', style='Wild.TLabel')
lbl32 = Label(frame3, text='R Y1', style='Wild.TLabel')
lbl33 = Label(frame3, text='R A1', style='Wild.TLabel')
lbl34 = Label(frame3, text='R B1', style='Wild.TLabel')
txt31 = Entry(frame3, width=5)
txt32 = Entry(frame3, width=5)
txt33 = Entry(frame3, width=5)
txt34 = Entry(frame3, width=5)
lbl51 = Label(frame3, text='C X1', style='Wild.TLabel')
lbl52 = Label(frame3, text='C Y1', style='Wild.TLabel')
lbl53 = Label(frame3, text=u'C \u03A61', style='Wild.TLabel')
txt51 = Entry(frame3, width=5)
txt52 = Entry(frame3, width=5)
txt53 = Entry(frame3, width=5)
frame3.grid_rowconfigure(3, minsize=10)
lbl35 = Label(frame3, text='R X2', style='Wild.TLabel')
lbl36 = Label(frame3, text='R Y2', style='Wild.TLabel')
lbl37 = Label(frame3, text='R A2', style='Wild.TLabel')
lbl38 = Label(frame3, text='R B2', style='Wild.TLabel')
txt39 = Entry(frame3, width=5)
txt40 = Entry(frame3, width=5)
txt41 = Entry(frame3, width=5)
txt42 = Entry(frame3, width=5)
lbl54 = Label(frame3, text='C X2', style='Wild.TLabel')
lbl55 = Label(frame3, text='C Y2', style='Wild.TLabel')
lbl56 = Label(frame3, text=u'C \u03A62', style='Wild.TLabel')
txt54 = Entry(frame3, width=5)
txt55 = Entry(frame3, width=5)
txt56 = Entry(frame3, width=5)
frame3.grid_rowconfigure(6, minsize=10)
lbl43 = Label(frame3, text='R X3', style='Wild.TLabel')
lbl44 = Label(frame3, text='R Y3', style='Wild.TLabel')
lbl45 = Label(frame3, text='R A3', style='Wild.TLabel')
lbl46 = Label(frame3, text='R B3', style='Wild.TLabel')
txt47 = Entry(frame3, width=5)
txt48 = Entry(frame3, width=5)
txt49 = Entry(frame3, width=5)
txt50 = Entry(frame3, width=5)
canvasm = Canvas(tab1, width=375, height=770, background='white', highlightthickness=1, relief = RAISED)
canvasm.grid(row=0, column=1, padx=28, pady=12)
frame2 = Frame(tab1)
frame2.grid(row=1, column=1, sticky="n")
frame2.grid_rowconfigure(0, minsize=3)
frame4 = Frame(tab1)
frame4.grid(row=1, column=0, sticky="w")
def zatvori_ovaj():
sub2.destroy()
broButton5 = Button(master=frame4, text='Back', style='Wild.TButton', width=8, command=lambda:[osnovni_prozor(),zatvori_ovaj()])
broButton5.grid(column=0, row=0, padx=35, pady=2, sticky="w")
broButton1 = Button(master=frame2, text='Show', style='Wild.TButton', width=8)
broButton1.grid(column=0, row=1, padx=8, pady=2)
broButton2 = Button(master=frame2, text='Folder', style='Wild.TButton', width=8)
broButton2.grid(column=1, row=1, padx=8, pady=2)
broButton3 = Button(master=frame2, text='Excel', style='Wild.TButton', width=8)
broButton3.grid(column=2, row=1, padx=8, pady=2)
broButton4 = Button(master=frame2, text='PDF', style='Wild.TButton', width=8)
broButton4.grid(column=3, row=1, padx=8, pady=2)
mainloop()
window = Tk()
s1 = Style()
s1.configure('Wild.TLabel', background='white', foreground='black')
s2 = Style()
s2.configure('Wild.TRadiobutton', background='white', foreground='black')
s3 = Style()
s3.configure('Wild.TButton', background='white', foreground='black')
w = 800
h = 850
window.wm_title("Cleanroom PanelGEN v1.0")
ws = window.winfo_screenwidth()
hs = window.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
window.geometry('%dx%d+%d+%d' % (w, h, x, y))
window.resizable(width=False, height=False)
window.configure(background='white')
window.minsize(800, 850)
window.maxsize(800, 850)
menu = Menu(window)
mainmenu = Menu(menu, tearoff=0)
menu.add_cascade(label='File', menu=mainmenu)
mainmenu.add_command(label='Generating parameters', command=spec_paneli)
mainmenu.add_command(label="Exit", command=window.destroy)
helpmenu = Menu(menu, tearoff=0)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label='Info')
window.config(menu=menu)
window.grid_rowconfigure(1, minsize=60)
window.grid_rowconfigure(6, minsize=150)
broButton = Button(master=window, text='Select', style='Wild.TButton', width=16)
broButton.grid(column=2, row=2, padx=45, pady=8)
broButton1 = Button(master=window, text='Select', style='Wild.TButton', width=16)
broButton1.grid(column=2, row=3, padx=45, pady=8)
broButton2 = Button(master=window, text='Generate G-Code', style='Wild.TButton', width=16)
broButton2.grid(column=1, row=7, padx=45, pady=8)
broButton3 = Button(master=window, text='Send to PLC', style='Wild.TButton', width=16)
broButton3.grid(column=1, row=8, padx=45, pady=8)
lbl0 = Label(window, text="Cleanroom PanelGEN v1.0", style='Wild.TLabel', anchor="e", font=("Arial Bold", 10))
lbl0.grid(column=1, row=0, columnspan=1, sticky=S)
lbl = Label(window, text="Selected file: ", style='Wild.TLabel')
lbl.grid(column=0, row=2, sticky=W, padx=29)
lbl2 = Label(window, text="Selected location: ", style='Wild.TLabel')
lbl2.grid(column=0, row=3, sticky=W, padx=29, pady=8)
lbl4 = Label(window, text="Select machine: ", style='Wild.TLabel')
lbl4.grid(column=0, row=4, sticky=W, padx=29, pady=8)
lbl4 = Label(window, text="Sheet metal width: ", style='Wild.TLabel')
lbl4.grid(column=0, row=5, sticky=W, padx=29, pady=8)
lbl5 = Label(window, text="FUNCTIONS:", style='Wild.TLabel')
lbl5.grid(column=0, row=7, sticky=W, padx=29, pady=8)
lbl1 = Label(window, text=naziv, style='Wild.TLabel', width=42, anchor="e")
lbl1.grid(column=1, row=2)
lbl3 = Label(window, text=lokacija, style='Wild.TLabel', width=42, anchor="e")
lbl3.grid(column=1, row=3)
combo = Combobox(window, state="readonly")
combo['values'] = ("DECA_NG_paneli", "DECA_NG_zaklopke", "DECA_Gradna_paneli", "Undefined")
combo.current(0)
combo.grid(column=2, row=4, pady=8)
txt1 = Entry(window, width=16, justify='center')
txt1.grid(column=2, row=5)
window.mainloop()