Files
2026-10-11 20:37:14 -04:00

54 lines
1.7 KiB
Python

import tkinter as tk
from tkinter import messagebox
from .gun_button import GunButton
class FrmGuns(tk.Toplevel):
def __init__(self, master, main_window):
super().__init__(master)
self.main_window = main_window
self.title("LBMS")
self.configure(bg="#404040")
self.resizable(False, False)
self.geometry("1010x507")
self.gun_buttons = []
self.protocol("WM_DELETE_WINDOW", lambda: None)
self.bind("<Double-Button-1>", self._on_double_click)
self.bind("<Configure>", lambda e: self.align_icons())
try:
self.state("zoomed")
except tk.TclError:
self.geometry("{}x{}".format(self.winfo_screenwidth(), self.winfo_screenheight()))
def add_gun_button(self, gun):
button = GunButton(self, gun)
self.gun_buttons.append(button)
return button
def align_icons(self):
try:
width = self.winfo_width()
height = self.winfo_height()
if width < 20 or height < 20:
return
item = 0
for y in range(6):
for x in range(8):
if item < len(self.gun_buttons):
c_control = self.gun_buttons[item]
c_control.place(
x=width / 8 * x + 10,
y=(height - 50) / 6 * y + 10,
width=width / 8 - 20,
height=(height - 20) / 6 - 20)
item += 1
except Exception:
pass
def _on_double_click(self, event):
if messagebox.askyesno("Quitter?", "Are you sure you want to exit?"):
self.main_window.root.destroy()