Skip to content

Commit

Permalink
show ip and port (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juice-XIJ authored Jan 2, 2022
1 parent 76efe6a commit cd255bb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions forza.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def __init__(self, threadPool: ThreadPoolExecutor, logger: Logger = None, packet
"""
super().__init__()

# === socket ===
self.ip = constants.ip
self.port = constants.port

# === logger ===
self.logger = (Logger()('Forza5')) if logger is None else logger

Expand Down
33 changes: 30 additions & 3 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def text_update(self, lang_index):
self.treeview.item(self.speed_level, text=self.speed_txt.get())
self.treeview.item(self.rpm_level, text=self.rpm_txt.get())

if hasattr(self, 'program_info'):
self.program_info.configure(state=tkinter.NORMAL)
self.program_info.delete("1.0", tkinter.END)
self.program_info.insert('1.0', self.program_info_txt.get())
self.program_info.configure(state=tkinter.DISABLED)

def update_tree(self):
"""Update shift point tree
"""
Expand Down Expand Up @@ -238,6 +244,21 @@ def set_language(event):
language_combobox.place(relx=0.08, rely=self.get_rely(pre_widget_count), anchor="w")
return pre_widget_count + 1

def place_ip_port(self, pre_widget_count=0):
self.ip_widget = tkinter.Text(self.car_info_frame, borderwidth=0, bg=constants.background_color, fg=constants.text_color, wrap=tkinter.WORD)
self.ip_widget.insert("1.0", f'IP: {self.forza5.ip}')
self.ip_widget.place(relx=0.08, rely=self.get_rely(pre_widget_count), relwidth=0.85, relheight=0.03, anchor="w")
self.ip_widget.configure(state="disabled")
pre_widget_count = pre_widget_count + 1

self.port_widget = tkinter.Text(self.car_info_frame, borderwidth=0, bg=constants.background_color, fg=constants.text_color, wrap=tkinter.WORD)
self.port_widget.insert("1.0", f'Port: {self.forza5.port}')
self.port_widget.place(relx=0.08, rely=self.get_rely(pre_widget_count), relwidth=0.85, relheight=0.03, anchor="w")
self.port_widget.configure(state="disabled")
pre_widget_count = pre_widget_count + 1

return pre_widget_count

def place_shortcuts(self, pre_widget_count=0):
"""place shortcuts comboboxes
"""
Expand Down Expand Up @@ -326,6 +347,9 @@ def set_car_setting_frame(self):
self.car_info_frame = tkinter.Frame(self.root, border=0, bg=constants.background_color, relief="groove", highlightthickness=True, highlightcolor=constants.text_color)
total_widget = 0

# ==== IP/Port setting ====
total_widget = self.place_ip_port(total_widget)

# ==== language setting ====
total_widget = self.place_languages(total_widget)

Expand Down Expand Up @@ -455,9 +479,12 @@ def set_program_info_frame(self):
"""
# place code info frame
self.program_info_frame = tkinter.Frame(self.root, border=0, bg=constants.background_color, relief="groove", highlightthickness=True, highlightcolor=constants.text_color)
label = tkinter.Label(self.program_info_frame, textvariable=self.program_info_txt, bg=constants.background_color, borderwidth=2, fg=constants.text_color, relief="groove", anchor="nw", justify=tkinter.LEFT)
label.bind('<Configure>', lambda e: label.config(wraplength=int(label.winfo_width() * 0.9)))
label.pack(fill="both", expand=True)

self.program_info = tkinter.Text(self.program_info_frame, borderwidth=0, bg=constants.background_color, fg=constants.text_color, wrap=tkinter.WORD)
self.program_info.insert("current", self.program_info_txt.get())
self.program_info.place(relx=0.03, rely=0.03, relwidth=0.95, relheight=0.95, anchor='nw', bordermode='inside')
self.program_info.configure(state="disabled")

self.program_info_frame.grid(row=1, column=2, sticky='news')

def collect_data_handler(self, event):
Expand Down
4 changes: 2 additions & 2 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def get_sys_lang():
def create_socket(forza: CarInfo):
forza.server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
forza.server_socket.settimeout(1)
forza.server_socket.bind((constants.ip, constants.port))
forza.logger.info(f'listening on IP {constants.ip}, Port {constants.port}')
forza.server_socket.bind((forza.ip, forza.port))
forza.logger.info(f'listening on IP {forza.ip}, Port {forza.port}')


def close_socket(forza: CarInfo):
Expand Down
Binary file modified img/f7_gui_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/f7_gui_test_zh_cn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cd255bb

Please sign in to comment.