I'm new and this could be basic, but I was trying to create windows forms using PAGE Editor and insert the results into a base code that I was created, but for any reason is not running into my base code (PAGE create two files as Pcode.py and Plotview_support.py). I created a function into my base code as Plot() and then I have pasted the result from Pcode.py PAGE Editor into this Plot() function.
Please any help to insert this code into my base code as Plot () function, which will be called by a menu or button using Plot().
Plotview_support.py is imported and any change in Pcode.py must be considered into it, also.
PAGE Edith Pcode.py as my function Plot()
def Plot():
import sys
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
from Modules import Plotview_support
# def vp_start_gui():
# '''Starting point when module is the main routine.'''
# global val, w, root
# root = tk.Tk()
# Plot
# view_support.set_Tk_var()
# top = PlotView(root)
# Plot
# view_support.init(root, top)
# root.mainloop()
w = None
def create_PlotView(rt, *args, **kwargs):
'''Starting point when module is imported by another module.
Correct form of call: 'create_PlotView(root, *args, **kwargs)' .'''
global w, w_win, root
# rt = root
root = rt
w = tk.Toplevel(root)
Plot
view_support.set_Tk_var()
top = PlotView(w)
Plot
view_support.init(w, top, *args, **kwargs)
return (w, top)
def destroy_PlotView():
global w
w.destroy()
w = None
class PlotView:
def __init__(self, top=None):
'''This class configures and populates the toplevel window.
top is the toplevel containing window.'''
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
_ana2color = '#ececec' # Closest X11 color: 'gray92'
self.style = ttk.Style()
if sys.platform == "win32":
self.style.theme_use('winnative')
self.style.configure('.', background=_bgcolor)
self.style.configure('.', foreground=_fgcolor)
self.style.configure('.', font="TkDefaultFont")
self.style.map('.', background=
[('selected', _compcolor), ('active', _ana2color)])
top.geometry("600x450+456+255")
top.minsize(120, 1)
top.maxsize(3844, 1061)
top.resizable(1, 1)
top.title("PlotView")
top.configure(background="#d9d9d9")
top.configure(highlightbackground="#d9d9d9")
top.configure(highlightcolor="black")
self.Entry_FN = tk.Entry(top)
self.Entry_FN.place(relx=0.15, rely=0.044, height=20, relwidth=0.473)
self.Entry_FN.configure(background="white")
self.Entry_FN.configure(disabledforeground="#a3a3a3")
self.Entry_FN.configure(font="TkFixedFont")
self.Entry_FN.configure(foreground="#000000")
self.Entry_FN.configure(highlightbackground="#d9d9d9")
self.Entry_FN.configure(highlightcolor="black")
self.Entry_FN.configure(insertbackground="black")
self.Entry_FN.configure(selectbackground="blue")
self.Entry_FN.configure(selectforeground="white")
self.Label1 = tk.Label(top)
self.Label1.place(relx=0.033, rely=0.044, height=21, width=74)
self.Label1.configure(activebackground="#f9f9f9")
self.Label1.configure(activeforeground="black")
self.Label1.configure(background="#d9d9d9")
self.Label1.configure(disabledforeground="#a3a3a3")
self.Label1.configure(foreground="#000000")
self.Label1.configure(highlightbackground="#d9d9d9")
self.Label1.configure(highlightcolor="black")
self.Label1.configure(text='''Full Name:''')
self.Frame1 = tk.Frame(top)
self.Frame1.place(relx=0.083, rely=0.2, relheight=0.767, relwidth=0.208)
self.Frame1.configure(relief='groove')
self.Frame1.configure(borderwidth="2")
self.Frame1.configure(relief="groove")
self.Frame1.configure(background="#d9d9d9")
self.Frame1.configure(highlightbackground="#d9d9d9")
self.Frame1.configure(highlightcolor="black")
self.Frame1_1 = tk.Frame(top)
self.Frame1_1.place(relx=0.333, rely=0.2, relheight=0.767
, relwidth=0.208)
self.Frame1_1.configure(relief='groove')
self.Frame1_1.configure(borderwidth="2")
self.Frame1_1.configure(relief="groove")
self.Frame1_1.configure(background="#d9d9d9")
self.Frame1_1.configure(highlightbackground="#d9d9d9")
self.Frame1_1.configure(highlightcolor="black")
self.Frame1_1_1 = tk.Frame(top)
self.Frame1_1_1.place(relx=0.583, rely=0.2, relheight=0.767
, relwidth=0.208)
self.Frame1_1_1.configure(relief='groove')
self.Frame1_1_1.configure(borderwidth="2")
self.Frame1_1_1.configure(relief="groove")
self.Frame1_1_1.configure(background="#d9d9d9")
self.Frame1_1_1.configure(highlightbackground="#d9d9d9")
self.Frame1_1_1.configure(highlightcolor="black")
self.TCombobox1 = ttk.Combobox(top)
self.TCombobox1.place(relx=0.15, rely=0.133, relheight=0.047
, relwidth=0.138)
self.TCombobox1.configure(textvariable=Plotview_support.combobox)
self.TCombobox1.configure(takefocus="")
self.Log1 = tk.Label(top)
self.Log1.place(relx=0.083, rely=0.133, height=21, width=35)
self.Log1.configure(activebackground="#f9f9f9")
self.Log1.configure(activeforeground="black")
self.Log1.configure(background="#d9d9d9")
self.Log1.configure(disabledforeground="#a3a3a3")
self.Log1.configure(foreground="#000000")
self.Log1.configure(highlightbackground="#d9d9d9")
self.Log1.configure(highlightcolor="black")
self.Log1.configure(text='''Log1:''')
self.Log2 = tk.Label(top)
self.Log2.place(relx=0.333, rely=0.133, height=21, width=35)
self.Log2.configure(activebackground="#f9f9f9")
self.Log2.configure(activeforeground="black")
self.Log2.configure(background="#d9d9d9")
self.Log2.configure(disabledforeground="#a3a3a3")
self.Log2.configure(foreground="#000000")
self.Log2.configure(highlightbackground="#d9d9d9")
self.Log2.configure(highlightcolor="black")
self.Log2.configure(text='''Log2:''')
self.TCombobox1_1 = ttk.Combobox(top)
self.TCombobox1_1.place(relx=0.4, rely=0.133, relheight=0.047
, relwidth=0.138)
self.TCombobox1_1.configure(textvariable=Plotview_support.combobox)
self.TCombobox1_1.configure(takefocus="")
self.TCombobox1_1_1 = ttk.Combobox(top)
self.TCombobox1_1_1.place(relx=0.65, rely=0.133, relheight=0.047
, relwidth=0.138)
self.TCombobox1_1_1.configure(textvariable=Plotview_support.combobox)
self.TCombobox1_1_1.configure(takefocus="")
self.Log3 = tk.Label(top)
self.Log3.place(relx=0.583, rely=0.133, height=21, width=35)
self.Log3.configure(activebackground="#f9f9f9")
self.Log3.configure(activeforeground="black")
self.Log3.configure(background="#d9d9d9")
self.Log3.configure(disabledforeground="#a3a3a3")
self.Log3.configure(foreground="#000000")
self.Log3.configure(highlightbackground="#d9d9d9")
self.Log3.configure(highlightcolor="black")
self.Log3.configure(text='''Log3:''')
create_PlotView(rt, *args, **kwargs)
The support Plotview_support.py imported is:
import sys
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
try:
import ttk
py3 = False
except ImportError:
import tkinter.ttk as ttk
py3 = True
def set_Tk_var():
global combobox
combobox = tk.StringVar()
def init(top, gui, *args, **kwargs):
global w, top_level, root
w = gui
top_level = top
root = top
def destroy_window():
# Function which closes the window.
global top_level
top_level.destroy()
top_level = None
if __name__ == '__main__':
import Plotview
Plotview.vp_start_gui()
Please any help will be appreciated!!!
question from:
https://stackoverflow.com/questions/65907267/using-page-gui-editor-code-to-insert-windows-into-my-python-code