start with notebook
This commit is contained in:
parent
5f30bee45f
commit
20a7e3c94a
103
gui/ser_one.py
103
gui/ser_one.py
@ -1,4 +1,5 @@
|
|||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
from tkinter.constants import W
|
||||||
import serial.tools.list_ports
|
import serial.tools.list_ports
|
||||||
import functools
|
import functools
|
||||||
import tkinter.ttk as ttk
|
import tkinter.ttk as ttk
|
||||||
@ -6,13 +7,10 @@ import tkinter.ttk as ttk
|
|||||||
import labrobot as lrb
|
import labrobot as lrb
|
||||||
|
|
||||||
|
|
||||||
|
# serial ports
|
||||||
ports = serial.tools.list_ports.comports()
|
ports = serial.tools.list_ports.comports()
|
||||||
serialObj = serial.Serial()
|
serialObj = serial.Serial()
|
||||||
|
|
||||||
root = tk.Tk()
|
|
||||||
root.config(bg='#b7f731')
|
|
||||||
|
|
||||||
|
|
||||||
def serial_ports():
|
def serial_ports():
|
||||||
return serial.tools.list_ports.comports()
|
return serial.tools.list_ports.comports()
|
||||||
|
|
||||||
@ -21,14 +19,51 @@ def on_select(event=None):
|
|||||||
serialObj.baudrate = 115200
|
serialObj.baudrate = 115200
|
||||||
serialObj.open()
|
serialObj.open()
|
||||||
|
|
||||||
cb =ttk.Combobox(root,values=serial_ports())
|
|
||||||
cb.grid(row=0,column=0,stick="we")
|
root = tk.Tk()
|
||||||
|
#configue root
|
||||||
|
root.title("Jfs Labrobot")
|
||||||
|
root.geometry('800x500+300+300')
|
||||||
|
root.columnconfigure(0,weight=1)
|
||||||
|
root.rowconfigure(0,weight=1)
|
||||||
|
#root.config(bg='#b7f731')
|
||||||
|
|
||||||
|
notebook = ttk.Notebook(root)
|
||||||
|
notebook.grid(sticky='news',padx=5,pady=5)
|
||||||
|
notebook.enable_traversalrightmainframe = ttk.Frame(notebook)
|
||||||
|
|
||||||
|
mainframe = ttk.Frame(notebook)
|
||||||
|
#mainframe.rowconfigure(0,weight=1)
|
||||||
|
mainframe.columnconfigure(0,weight=1)
|
||||||
|
|
||||||
|
notebook.add(mainframe,text='main',underline=0)
|
||||||
|
|
||||||
|
leftframe = ttk.Frame(mainframe)
|
||||||
|
|
||||||
|
leftframe.columnconfigure(0,weight=1)
|
||||||
|
leftframe.rowconfigure(1,weight=1)
|
||||||
|
leftframe.grid(column=0,row=0,sticky='news')
|
||||||
|
|
||||||
|
rightframe = ttk.Frame(mainframe)
|
||||||
|
rightframe.columnconfigure(0,weight=1)
|
||||||
|
rightframe.rowconfigure(0,weight=1)
|
||||||
|
rightframe.grid(column=1,row=0,sticky='new')
|
||||||
|
|
||||||
|
uprightframe =ttk.LabelFrame(rightframe,text='Basic')
|
||||||
|
uprightframe.grid(column=0,row=0,sticky='ns')
|
||||||
|
|
||||||
|
downrightframe =ttk.LabelFrame(rightframe,text='More to select')
|
||||||
|
downrightframe.grid(column=0,row=1,sticky='new',pady=5)
|
||||||
|
|
||||||
|
cb =ttk.Combobox(leftframe,values=serial_ports())
|
||||||
|
cb.grid(row=0,column=0,stick="nwe")
|
||||||
cb.bind('<<ComboboxSelected>>',on_select)
|
cb.bind('<<ComboboxSelected>>',on_select)
|
||||||
|
|
||||||
scb =tk.Scrollbar(root)
|
scb =tk.Scrollbar(leftframe)
|
||||||
scb.grid(row=1,column=1,rowspan=10,sticky='ns')
|
scb.grid(row=1,column=1,sticky='ns')
|
||||||
txt = tk.Text(root,height=20,width=50)
|
#txt = tk.Text(leftframe,height=30,width=50)
|
||||||
txt.grid(row=1,column=0,rowspan=10)
|
txt = tk.Text(leftframe)
|
||||||
|
txt.grid(row=1,column=0,sticky='ewns')
|
||||||
scb.config(command=txt.yview)
|
scb.config(command=txt.yview)
|
||||||
txt.config(yscrollcommand=scb.set)
|
txt.config(yscrollcommand=scb.set)
|
||||||
txt.tag_configure('small',font=('Verdana',8),foreground='black')
|
txt.tag_configure('small',font=('Verdana',8),foreground='black')
|
||||||
@ -69,45 +104,17 @@ def nextTip():
|
|||||||
downTip()
|
downTip()
|
||||||
|
|
||||||
|
|
||||||
b1 = tk.Button(root,bg='#000000',
|
b1 = tk.Button(uprightframe,text='Home All',width=12,command=homeAll).grid(row=0,column=0,sticky='nw')
|
||||||
fg='#b7f731',
|
b2 = tk.Button(uprightframe,text='Home X',width=12,command=homeX).grid(row=0,column=1,sticky='ne')
|
||||||
relief='flat',text='Home All',width=12,command=homeAll)
|
b3 = tk.Button(uprightframe,text='Home Y',width=12,command=homeY).grid(row=1,column=0,sticky='nw')
|
||||||
b1.grid(row=0,column=2,sticky='nw')
|
b4 = tk.Button(uprightframe,text='Home Z',width=12,command=homeZ).grid(row=1,column=1,sticky='ne')
|
||||||
b2 = tk.Button(root,bg='#000000',
|
b6 = tk.Button(uprightframe,text='Home P',width=12,command=homeP).grid(row=2,column=0,sticky='nw')
|
||||||
fg='#b7f731',
|
b7 = tk.Button(uprightframe,text='Get Position',width=12,command=getPos).grid(row=2,column=1,sticky='ne')
|
||||||
relief='flat',text='Home X',width=12,command=homeX)
|
l1 = tk.Label(uprightframe,text="Enter G-Code").grid(row=3,column=0)
|
||||||
b2.grid(row=1,column=2,sticky='nw')
|
e1 = tk.Entry(uprightframe).grid(row=3,column=1)
|
||||||
b3 = tk.Button(root,bg='#000000',
|
b5 = tk.Button(uprightframe,text='Send Code',command=do_gcode).grid(row=4,column=1,sticky="ne")
|
||||||
fg='#b7f731',
|
|
||||||
relief='flat',text='Home Y',width=12,command=homeY)
|
|
||||||
b3.grid(row=2,column=2,sticky='nw')
|
|
||||||
b4 = tk.Button(root,bg='#000000',
|
|
||||||
fg='#b7f731',
|
|
||||||
relief='flat',text='Home Z',width=12,command=homeZ)
|
|
||||||
b4.grid(row=3,column=2,sticky='nw')
|
|
||||||
b6 = tk.Button(root,bg='#000000',
|
|
||||||
fg='#b7f731',
|
|
||||||
relief='flat',text='Home P',width=12,command=homeP)
|
|
||||||
b6.grid(row=4,column=2,sticky='nw')
|
|
||||||
b7 = tk.Button(root,bg='#000000',
|
|
||||||
fg='#b7f731',
|
|
||||||
relief='flat',text='Get Position',width=12,command=getPos)
|
|
||||||
b7.grid(row=5,column=2,sticky='nw')
|
|
||||||
|
|
||||||
l1 = tk.Label(root,bg='#000000',
|
b8 = tk.Button(downrightframe,text='Next Tip',command=nextTip).grid(row=0,column=0,sticky='ne')
|
||||||
fg='#b7f731',
|
|
||||||
relief='flat',text="Enter G-Code")
|
|
||||||
l1.grid(row=0,column=3)
|
|
||||||
|
|
||||||
e1 = tk.Entry(root)
|
|
||||||
e1.grid(row=0,column=4)
|
|
||||||
b5 = tk.Button(root,bg='#000000',
|
|
||||||
fg='#b7f731',
|
|
||||||
relief='flat',text='Send Code',command=do_gcode)
|
|
||||||
b5.grid(row=1,column=4,sticky="ne")
|
|
||||||
|
|
||||||
b8 = tk.Button(root,bg='#000000', fg='blue',relief='flat',text='Next Tip',command=nextTip)
|
|
||||||
b8.grid(row=2,column=4,sticky='ne')
|
|
||||||
|
|
||||||
def checkSerialPort():
|
def checkSerialPort():
|
||||||
if serialObj.isOpen() and serialObj.in_waiting:
|
if serialObj.isOpen() and serialObj.in_waiting:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user