added start botton to the bottom left corner

This commit is contained in:
Seth Samuel 2024-11-25 14:50:31 +13:00
parent eb116803d0
commit 44ef5ce6cb

View file

@ -9,6 +9,7 @@ import sys
from enum import Enum
import tkinter
from GAME_METHODS import *
import functools #used for passing variables into callbacks
##check if python 3.11 is running code and exit if not
@ -25,6 +26,7 @@ BEAMNG_UDP_PORT = 4444
FORZA_UDP_PORT= 4843
SERIAL_PORT = ""
firstRun= True #used to do the headers for csv files
pushingToArduino = False
class GameType(Enum):
NONE=0
@ -63,11 +65,22 @@ else:
print("OS detection failed setting serial port to 'COM5'\n")
SERIAL_PORT = 'COM5'
def startStopButtonFunc():
global pushingToArduino
if pushingToArduino == True:
startStopButton.config(text="start")
pushingToArduino = False
elif pushingToArduino == False:
startStopButton.config(text="stop")
pushingToArduino = True
##GUI init
rootFrameGui= tkinter.Tk()
rootFrameGui.title("Car speed to arduino")
rootFrameGui.geometry("400x200")
bottomBarFrameGui = tkinter.ttk.Frame(rootFrameGui,padding=0,relief="groove",borderwidth=2,)
bottomBarFrameGui.pack(anchor="se",side="bottom",fill="x")
firstFrameGui=tkinter.ttk.Frame(rootFrameGui,padding=2,relief="groove",borderwidth=2)
firstFrameGui.pack(anchor="ne",side="left",expand=True)
secondFrameGui=tkinter.ttk.Frame(rootFrameGui,padding=2,relief="groove",borderwidth=2)
@ -99,10 +112,16 @@ loggingFrameGui= tkinter.ttk.Frame(firstFrameGui,padding=5,relief="groove",borde
loggingFrameGui.pack(anchor="nw")
tkLoggingEnabled=tkinter.BooleanVar()
tkLoggingEnabled.set(False)
tkinter.Checkbutton(loggingFrameGui,text="Enable Logging",variable=tkLoggingEnabled,onvalue=True,offvalue=False).pack(side="bottom")
tkinter.Checkbutton(loggingFrameGui,text="Enable Logging",variable=tkLoggingEnabled,onvalue=True,offvalue=False).pack(side="top")
loggingLocationText = tkinter.StringVar(value= "./")
loggingLocationEntry = tkinter.Entry(loggingFrameGui)
loggingLocationEntry.insert(0,loggingLocationText.get())
loggingLocationEntry.pack(side="bottom")
startStopButton= tkinter.Button(bottomBarFrameGui,text= "start",command= startStopButtonFunc)
startStopButton.pack(side="right",fill="x")
rootFrameGui.mainloop()
##exit() #### exit for testing
exit() #### exit for testing
#select game
while gameSelected == False:
gameNo = input("1:BEAMNG\n2:FORZA\n\n7:Toggle CSV out ("+str(csvOut)+")\n9:SET SERIAL PORT ("+SERIAL_PORT+")\n")