The discussion of the Alien series of films and the props used in them is the aim, but if it's got Big Bugs and Big Guns, then they are welcome too!





Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re:
PostPosted: Thu Apr 08, 2021 1:44 pm 

Location: Derby
Country: United Kingdom
knoxvilles_joker wrote:
The key is to have the window so it is resizable so we can use the thing as a main attraction at our fan table with all of the hacked grid case setups we have out there now amongst our group.


yep agreed, this should be quite easy really. If you want to maintain the application as something that is re-sizable and windowed then you can render out to a surface of known size (i.e. 640x200) and then re-scale using the pygame.transform.scale function keyed to the resized window size. If your application display has been defined with the FULLSCREEN flag then the scaling is applied automatically to meet the current display size. i've tried this with my test rig and it's working. The only issue with the scaling is that there does seem to be a loss of fidelity on the re-sized image, especially for larger resolutions.

i've attached version 1 of the font if you want to try it. I'm not a font expert so it may need re-work. This is the jagged version.

Attachment:
sentryterminal .zip [7.27 KiB]
Downloaded 3 times


Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: Fri Apr 09, 2021 11:23 pm 

Service Number: A05/TQ2.0.32141E1
Country: United States
martinr1000 wrote:
knoxvilles_joker wrote:
The key is to have the window so it is resizable so we can use the thing as a main attraction at our fan table with all of the hacked grid case setups we have out there now amongst our group.


yep agreed, this should be quite easy really. If you want to maintain the application as something that is re-sizable and windowed then you can render out to a surface of known size (i.e. 640x200) and then re-scale using the pygame.transform.scale function keyed to the resized window size. If your application display has been defined with the FULLSCREEN flag then the scaling is applied automatically to meet the current display size. i've tried this with my test rig and it's working. The only issue with the scaling is that there does seem to be a loss of fidelity on the re-sized image, especially for larger resolutions.

i've attached version 1 of the font if you want to try it. I'm not a font expert so it may need re-work. This is the jagged version.

Attachment:
sentryterminal .zip


Ugg. OK, you did a really great attempt. I will use the Sentry gun flash program as a basis and hash out things and see if my touches fare any better. Good start. It is just hard to do pixel by pixel recreations on a screen grab.

Honestly I would pay money to talk to whomever designed the original sentry gun setup in the movie.

Fidelity will disappear as things are resized. This is a given but helps when you are trying to guestimate things.

The font itself is a hybrid font of several to achieve the look. It was most likely a true type font or TTF as they are called. No single font set matches what we saw in the film. Based on what we saw it is a BOLD True Type Font. Not an Italicized or underlined TTF. That we are only dealing with a bold version of the font we are lucky. We only have to deal with one set of a font grouping. We do not have to build the 10 different types and already have the specs on the font size and pitch to use.

Screen pitch is a measurement of the distance between the pixels. This was a big thing in CRT monitors back in the day and even in primitive LCD displays. The smaller the pitch the more of a high resolution image you could produce in a smaller screen.

To put it in perspective your smartphone device has a resolution that exceeds that of the highest resolution a 486 computer could produce in the x286 family series of processors.

Now let us delve into printing. You have two main print driver formats:
Printer Control Language (PCL) up to version 6 enhanced or 6e now I believe
Adobe Post Script (PS)

A guy working for Xerox saw the potential for a universal print driver language that could work with any printer or computer. Up until the 70s all printers and drivers were proprietary setups. Think the copier scene in the movie 9 to 5. That is all that was available. Xerox nixed the guys idea.

A year later adobe was born and it became a staple of the printer industry in the 70s. THen comes along Hewlett Packard and they see the potential and create the PCL language for its dot matrix and inkjet based printers. Many copy them and use their printer driver standard over the years. PCL version 1 was introduced in the 70s. For decades PCL and PS drivers and hardware based support of them was exclusive. Now most all printers can emulate either or one or the other. Some printer manufacturers prefer one driver type over others. But with virtualization and clustering thanks to VMware and IBM blades drivers have moved more to a universal standard by manufacturer. CUPS(Common Unix Printing System) for Linux/UNIX setups came to be around 1997. This gave birth to the multi platform support we see for all the prtiners now. Why do I know this? I supported printers at a previous job for a decade. Explaining why this or that driver worked better with a given os and software helps make the user understand and get the, "aha" moment much more quickly to lessen the amount of support calls and issues.

TTF is more of a windows type of font and is a very generic business font form. Usually used for business typesetting and logo brand/trade mark type deals. And that is why there are so darned many of them. The key in all of this is to ensure you are not stepping on the toes of an existing copyright. As there is no profit involved we have a lot more leeway but still have to be careful.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: idea on flash replacement for sentry gun terminal progra
PostPosted: Fri Apr 09, 2021 11:40 pm 

Service Number: A05/TQ2.0.32141E1
Country: United States
martinr1000 wrote:
Also i was reading that the max resolution of the gridcase could be 640x400 because of dual scan. Wondering if this is possible and whether or not it would make more sense in terms of the proportions of the terminal software that we see. 640x200 looks a bit thin to me but i am no expert in this area. (the pics above are based on 640x400)

cheers


The dual scan was a cheat to fit the same space on a smaller screen physically. The efficiencies we are used to now did not exist back then, let alone the number of dejure and industry standards.

There were a lot of hardware hacks and cheats that were done back then to make limited hardware perform beyond its technical limitations. This is in part why there is such a love amongst the hardcore programming communities of the old games as the rock solid code and tightness of memory usage is not something we can as easily replicate now a days.

Java is going away as it was never a language to start with and HTML is finally catching up to a point where it can replace that and Java Virtual Machine(JVM) from the days of old. Languages and standards were made as the basis of usage was not there yet to have the core browsers handle everything. Once we started having exploits and bugs galore thanks to hackers ethical and otherwise more focus was put in of late to secure things and minimize the external software pieces needed for web browsers to function.

Python across the board is gaining more popularity so I, "THINK," this will be a safe medium for now.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Apr 11, 2021 6:30 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
OK, I got the fire counter to trigger when the "f" key was pressed. I just need to figure out a good reset and reload methodology for it as right now it will run negative add infinity.

Code:
import pygame
from tkinter import *
import tkinter
import keyboard
import pynput

pygame.init()

# Create object
root = tkinter.Tk()

# Adjust size
root.geometry("640x400")
root.configure(bg='black')
root.title("Sentry Terminal")
var = StringVar()
var = 500

def count(event):
  global counter
  counter.set(counter.get() - 1)

counter = tkinter.IntVar()
counter.set(500)

Grid.rowconfigure(root,0,weight=1, uniform='a')
Grid.columnconfigure(root,0,weight=1, uniform='a')
Grid.rowconfigure(root,1,weight=1, uniform='b')
Grid.columnconfigure(root,1,weight=1, uniform='b')

rounds = Button(root,justify=CENTER,textvariable=var)
rounds.grid(row=0,column=0, sticky="EW")
label1 = Label(root, textvariable=counter)
label1.grid(row=1, column=0, sticky="EW")
root.bind("<KeyPress-f>", count)

while True:
  root.mainloop()

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Apr 11, 2021 7:15 pm 

Service Number: A05/TQ2.0.32141E1
Country: United States
Thanks to the folks at python-forum.io this code has a self resetting counter:

Code:
import tkinter as tk
 
 
INITIAL_COUNTER_VALUE = 500
 
 
class TkApp(tk.Tk):
 
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry("640x400")
        self.configure(bg='black')
        self.title("Sentry Terminal")
        self.counter = tk.IntVar()
        self.counter.set(INITIAL_COUNTER_VALUE)
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='b')
        rounds = tk.Button(self, justify=tk.CENTER, textvariable=self.counter)
        rounds.grid(row=0, column=0, sticky="EW")
        label1 = tk.Label(self, textvariable=self.counter)
        label1.grid(row=1, column=0, sticky="EW")
        self.bind("<KeyPress-f>", self.on_keypress_f)
 
    def on_keypress_f(self, evet):
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)
 
 
tk_app = TkApp()
tk_app.mainloop()

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 12, 2021 3:47 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
This is the latest progress:

Code:
import tkinter.ttk as ttk
import tkinter as tk
 
# sets ammo count to initial value of 500
INITIAL_COUNTER_VALUE = 500
# sets initial time at 100%
INITIAL_TIMER_VALUE = 33000
# sets initial gun terminal ID
#sets gun rate
RMMAX = 0
# sets initial temparature
TEMP_INITIAL = 30
# sets text string for ammo/temp/low ammo status button
STATUS = "OK"
# initial class declaration for main body of program
class TkApp(tk.Tk):
# these arguments initialize the class and how to form arguments within
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # set screen options
        self.geometry("640x400")
        self.configure(bg='black')
        self.title("Sentry Terminal")
        # locally initialize ammo count down
        self.counter = tk.IntVar()
        self.counter.set(INITIAL_COUNTER_VALUE)
        # locally sets the timer count down at 100%
        self.timer = tk.IntVar()
        self.timer.set(INITIAL_TIMER_VALUE)
        # locally sets rmbar to 0%
        self.rmcount = tk.IntVar()
        self.rmcount.set(RMMAX)
        # locally sets tempbar
        self.temperature = tk.IntVar()
        self.temperature.set(TEMP_INITIAL)
        # locally sets text string for ammo status button
        self.stat = tk.StringVar()
        self.stat.set(STATUS)
        # this arranges the grid row and column groupings. 
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='c')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 3, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 4, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 5, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 6, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 7, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 8, weight=1, uniform='b')

        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 3, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 4, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 5, weight=1, uniform='a')

        # these are the button and label declarations
        rounds = tk.Label(self, justify=tk.CENTER, textvariable=self.counter)
        rounds.grid(row=3, column=2, columnspan=1, sticky="EW")
        label1 = tk.Label(self, textvariable=self.timer)
        label1.grid(row=7, column=2, sticky="EW")
        temp = tk.Button(self,justify=tk.CENTER,text="Temp",bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        temp.grid(row=2,column=4,sticky="NSEW")
        rm = tk.Button(self,justify=tk.CENTER,text="R(M)",bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        rm.grid(row=2,column=5,sticky="NSEW")
        # rounds rate bar
        rmbar = ttk.Progressbar(self, orient="vertical", variable=self.rmcount)
        rmbar.grid(row=3,column=5,rowspan=6, sticky="NS")
        # temperature bar
        tempbar = ttk.Progressbar(self, orient="vertical", variable=self.temperature)
        tempbar.grid(row=3,column=4,rowspan=6,sticky="NS")
        # declarative buttons
        timestat = tk.Button(self,bg='black',state=tk.DISABLED, fg='yellow',disabledforeground='yellow',highlightbackground='yellow',borderwidth=2,justify=tk.CENTER,text="TIME AT 100% \n (msecs)")
        timestat.grid(row=7,column=0,columnspan=2,sticky="NSEW")
        roundsr = tk.Button(self,bg='black',state=tk.DISABLED, fg='yellow',disabledforeground='yellow',highlightbackground='yellow',borderwidth=2,justify=tk.CENTER,text="Rounds \n Remaining")
        roundsr.grid(row=3,column=0,columnspan=2,sticky="NS")


        # crit menu bar
        crit = tk.Button(self,justify=tk.CENTER,textvariable=self.stat, bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        crit.grid(row=5,column=0,columnspan=2,sticky="NSEW")
       

        # static center header
        headernew = tk.Button(self, bg='black',state=tk.DISABLED,justify=tk.CENTER, text="UA 571-C \n REMOTE SENTRY WEAPON SYSTEM")
        headernew.grid(row=0,column=1,columnspan=4,rowspan=2,sticky="NSEW")
        # displays gun id on top left and right of screen
        gun_1 = tk.Label(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,text="kp")
        gun_1.grid(row=0,column=0,rowspan=2,sticky="NS")
        gun_2 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,text="kp")
        gun_2.grid(row=0,column=5,rowspan=2,sticky="NS")


        # this quits by clicking a button labeled q
        quit = tk.Button(self, bg='black', fg='yellow', text='q', command=self.quit)
        quit.grid(row=8,column=0,sticky="SW")

        # these are the attachments for input from keyboard into the application
        # These are the button inputs from the original flash app that were used
        # I added a q as well to quit and close window in case there was a need to close

        self.bind("<KeyPress-f>", self.on_keypress_f)
        self.bind("<KeyRelease-f>", self.on_keyrelease_f)
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.bind("<KeyPress-space>", self.on_keypress_space)

    # this defines the fire ammo count down sequence and resets
    def on_keypress_f(self, evet):
       
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)
        # this is logic to try and get ammo warnings
        if counter_value == 490:
         
          stat_value = "OUT"
        else:
          stat_value = "OK"
          self.stat.set(stat_value)
        # this sets the time at 100%
        timer_value = self.timer.get()
        timer_value = timer_value-66 or INITIAL_TIMER_VALUE
        self.timer.set(timer_value)
        # this sets the rmbar to 40%
        rmcount_count = self.rmcount.get()
        rmcount_count = 40
        self.rmcount.set(rmcount_count)
        # this sets the temperature
        temperature_count =  self.temperature.get()
        temperature_count = temperature_count+1
        self.temperature.set(temperature_count)
    def on_keyrelease_f(self, evet):
        #this adds logic to say rate is zero if not firing
        rmcount_count = self.rmcount.get()
        rmcount_count = 0
        self.rmcount.set(rmcount_count)
        # this adds logic to say if not firing cool down
        temperature_count =  self.temperature.get()
        temperature_count = temperature_count-10
        self.temperature.set(temperature_count)
   
    # this sets the gun terminal identification
    # this can also be expanded to do other things if you want to alter the script
    def on_keypress_a(self, evet):
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)

    def on_keypress_b(self, evet):
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)

    def on_keypress_c(self, evet):
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)

    def on_keypress_d(self, evet):
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)

    def on_keypress_space(self, evet):
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)

# this reloads the window, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()

# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()
 
# this executes the main loop and tkinter self delcared class.  It declares the function then runs it in the main loop.
tk_app = TkApp()
tk_app.mainloop()

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 13, 2021 2:19 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
as it stands I have left to do the overheat and out of ammo alerts and an automatic cool down on the gun temperature gauge.

I had to deviate on time and switch to msec instead of secs. I could do more digging and see if I can get the floating number piece to work but there are limitations of the programing language or my knowledge of how to properly apply said language.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 13, 2021 6:19 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
OK this is the related thread on another forum where I reached out on help:
https://python-forum.io/Thread-Tkinter- ... ss-counter

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Apr 16, 2021 10:00 pm 

Service Number: A05/TQ2.0.32141E1
Country: United States
Cursory investigations for android compatibility indicate I will need to program with their google play API:
https://developers.google.com/android-publisher
Android is closer to Linux at its heart but is closed open source with the google tie ins. For massive and easy distribution we want to go with the google play store compatibility.

For apple I will need to use an apple OS based device to program with their swift programming language. Apple basically sandboxes everything and usually likes clean self contained c like stuff.

In both cases they have tried to make programming easy. I will create separate threads for those once I get to that point. Each one will have a separate thread to lower confusion.

Once I get the logic piece sorted out for python and things working I will start with android and then IOS. The goal is easy use and minimal actions required to make things work. I refuse to make things too complicated over unnecessarily complicated for the end user.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 17, 2021 8:31 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
I got the splash screen looking like the flash program. I am not happy that I am unable to resize it, but, it looks very similar to the original.

keyboard navigation appears spot on. I still have to work through the sentry terminal letter disgnations in the header and the the cooldown decrement counter and outside of those two I just have to get the label to update on the temperature and ammo count warning and this is going to be finished.

Code:
import tkinter as tk
from tkinter import *
#import PIL.ImageTk
#import image
#import PIL
#import PIL.Image
import tkinter.ttk as ttk
import datetime as dt
import time
import os
from tkinter import messagebox
#
# global variables will be declared here



# end global variables section
#
# This is the initial screen that loads and then disappears after 8 seconds
# I used 3 images to make the main deal.  The issue was that pygame allowed for line draws
# tkinter only allows for drawing of boxes. 
# should this change I will change from using images.
class SplashFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Iniitaling")
        self.img = tk.PhotoImage(file='load5.png')
        self.configure(background='black')
        self.overrideredirect(True)
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='a')
        self.leftimage = PhotoImage(file='loadleft22.png')
        left = ttk.Label(self, style="TLabel", image=self.leftimage)
        left.grid(row=2, column=0, sticky="NSEW")
        self.rightimage = PhotoImage(file='loadright3.png')
        right = ttk.Label(self, style="TLabel", image=self.rightimage)
        right.grid(row=2, column=2, sticky="NSEW")
        btn = tk.Label(self, image=self.img)
        btn.grid(row=0, rowspan=2, column=0, columnspan=3, sticky="NSEW")
        styled = ttk.Style()
        styled.theme_use('clam')
        styled.configure("TLabel", background='black', darkcolor='black', bordercolor='black', relief='none', lightcolor='black', highlightcolor='black', foreground='black', shiftrelief=-5, highlightthickness=0, width=0, anchor="NSEW")
        styled.configure("Horizontal.TProgressbar", foreground = 'black', background = 'yellow', bordercolor='black', darkcolor='black', throughcolor='black', lightcolor='black')
        loadingbar = ttk.Progressbar(self, style="Horizontal.TProgressbar", orient="horizontal", length = 200, mode='indeterminate', maximum=100)
        loadingbar.grid(row=2, column=1, sticky="NEW")
        loadingbar.start([78])
        self.overrideredirect(True)
# self.after has a timer in msecs.  Just change this to your desired value.  I have logic on loading bar set for 8 seconds so if you change that
# you will need to adjust the loadingbar.start number.  Remember it is 200 units long and you divide that by the time in msecs to figure out how to divide up the movement
        self.after(1000, self.destroy)
#
# End of splash screen defined class and related functions
#
# Begin select menu defined class and related functions
# This is the script's core window so more code will be present here than in other sections

# This is the next screen to load after the initial splash screen
class TkApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Select Screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Button(self, text='SecondFrame', command=self.on_button).grid(row=0, column=0, sticky="NSEW")
        self.create_splashframe()

        # These are the bind key definitions
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)


 # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()
# this launches the next screen, the fire select screen
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()
    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()

# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
    def on_keypress_a(self, evet):
        print("a pressed")
    def on_keypress_b(self, evet):
        print("b pressed")
    def on_keypress_c(self, evet):
        print("c pressed")
    def on_keypress_d(self, evet):
        print("d pressed")

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()

#
#
#
#
# this is the third fire screen
class SecondFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Fire status screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Button(self, text='Close', command=self.destroy).grid(row=0, column=0, sticky="NSEW")


        # These are the bind key definitions
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()




    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
    def on_keypress_a(self, evet):
        print("a pressed")
    def on_keypress_b(self, evet):
        print("b pressed")
    def on_keypress_c(self, evet):
        print("c pressed")
    def on_keypress_d(self, evet):
        print("d pressed")

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()






#
#
# End fire menu class and related functions
#
#
#Begin secret credits(kudos) screen
#
#q

class KudosFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Secret credits screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Button(self, text='Close', command=self.destroy).grid(row=0, column=0, sticky="NSEW")

        # These are the bind key definitions
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()
    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()



# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
    def on_keypress_a(self, evet):
        print("a pressed")
    def on_keypress_b(self, evet):
        print("b pressed")
    def on_keypress_c(self, evet):
        print("c pressed")
    def on_keypress_d(self, evet):
        print("d pressed")

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()


#
# End secret credits(kudos) screen
#
#
#
# The below two commands run the entire script

tk_app = TkApp()
tk_app.mainloop()

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Apr 17, 2021 8:39 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
This is the initial build for the select menu. I just have to transform it into a class function to fit into the main splash script.

Code:
from collections import deque
from itertools import islice
from tkinter import *
import tkinter

 
# Create object
root = tkinter.Tk()
 
# Adjust size
root.geometry("640x300")
root.configure(bg='black')
 
# Specify Grid
Grid.rowconfigure(root, 0, weight=1, uniform='a')
Grid.rowconfigure(root, 1, weight=1, uniform='b')
Grid.rowconfigure(root, 2, weight=1, uniform='b')
Grid.rowconfigure(root, 3, weight=1, uniform='b')
Grid.rowconfigure(root, 4, weight=1, uniform='b')
Grid.rowconfigure(root, 5, weight=1, uniform='b')
Grid.rowconfigure(root, 6, weight=1, uniform='b')
Grid.rowconfigure(root, 7, weight=1, uniform='b')
Grid.rowconfigure(root, 8, weight=1, uniform='b')
Grid.rowconfigure(root, 9, weight=1, uniform='b')
Grid.columnconfigure(root, 0, weight=1, uniform='d')
Grid.columnconfigure(root, 1, weight=1, uniform='d')
Grid.columnconfigure(root, 2, weight=1, uniform='d')
Grid.columnconfigure(root, 3, weight=1, uniform='d')
Grid.columnconfigure(root, 4, weight=1, uniform='d')
Grid.columnconfigure(root, 5, weight=1, uniform='d')
Grid.columnconfigure(root, 6, weight=1, uniform='d')
Grid.columnconfigure(root, 7, weight=1, uniform='d')


button_1 = Button(root, justify=CENTER, text="AUTO-REMOTE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
button_2 = Button(root, justify=CENTER, text="HARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
button_3 = Button(root, justify=CENTER, text="SEMIHARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
button_4 = Button(root, justify=CENTER, text="SOFT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
sbutton_1 = Button(root, justify=CENTER, text="BIO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
sbutton_2 = Button(root, justify=CENTER, text="INERT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
tsbutton_1 = Button(root, justify=CENTER, text="MULTI SPEC", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
tsbutton_2 = Button(root, justify=CENTER, text="INFRA RED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
tsbutton_3 = Button(root, justify=CENTER, text="UV", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
wsbutton_1 = Button(root, justify=CENTER, text="SAFE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
wsbutton_2 = Button(root, justify=CENTER, text="ARMED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
isbutton_1 = Button(root, justify=CENTER, text="SEARCH", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
isbutton_2 = Button(root, justify=CENTER, text="TEST", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
isbutton_3 = Button(root, justify=CENTER, text="ENGAGED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
isbutton_4 = Button(root, justify=CENTER, text="INTERROGATE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
trbutton_1 = Button(root, justify=CENTER, text="AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
trbutton_2 = Button(root, justify=CENTER, text="SELECTIVE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
smman = Button(root, justify=CENTER, text="MAN-OVERRIDE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
smauto = Button(root, justify=CENTER, text="SEMI-AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
gun_1 = Button(root, borderwidth=7, bg='black', relief=RIDGE,disabledforeground='yellow', state=DISABLED, text="kp")
gun_2 = Button(root, borderwidth=7, bg='black', fg='yellow',disabledforeground='yellow', state=DISABLED, text="kp")
# header = Button(root, image = photo, compound = TOP) # image reference
headernew = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="UA 571-C \n REMOTE SENTRY WEAPON SYSTEM")
syst = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SYSTEM \n   MODE")
weap = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="WEAPON \n   STATUS")
iff = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="IFF \n   STATUS")
test = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TEST \n   ROUTINE")
target = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET PROFILE")
spectral = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SPECTRAL PROFILE")
ts = Button(root, bg='black', state=DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET SELECT")

gun_1.grid(row=0, column=0, ipadx=2, ipady=2, padx=2, pady=2, sticky=W)
gun_2.grid(row=0, column=7, ipadx=2, ipady=2, padx=2, pady=2, sticky=E)
headernew.grid(row=0, column=1, columnspan=6, sticky="NSEW")
button_1.grid(row=2, column=0, columnspan=2, sticky="NSEW")
button_2.grid(row=9, column=0, columnspan=3, sticky="NSEW")
button_3.grid(row=8, column=0, columnspan=3, sticky="NSEW")
button_4.grid(row=7, column=0, columnspan=3, sticky="NSEW")
sbutton_1.grid(row=7, column=3, columnspan=2, sticky="NSEW")
sbutton_2.grid(row=8, column=3, columnspan=2, sticky="NSEW")
tsbutton_1.grid(row=7, column=5, columnspan=3, sticky="NSEW")
tsbutton_2.grid(row=8, column=5, columnspan=3, sticky="NSEW")
tsbutton_3.grid(row=9, column=5, columnspan=3, sticky="NSEW")
wsbutton_1.grid(row=2, column=2, columnspan=2, sticky="NSEW")
wsbutton_2.grid(row=3, column=2, columnspan=2, sticky="NSEW")
isbutton_1.grid(row=2, column=4, columnspan=2, sticky="NSEW")
isbutton_2.grid(row=3, column=4, columnspan=2, sticky="NSEW")
isbutton_3.grid(row=4, column=4, columnspan=2, sticky="NSEW")
isbutton_4.grid(row=5, column=4, columnspan=2, sticky="NSEW")
trbutton_1.grid(row=2, column=6, columnspan=2, sticky="NSEW")
trbutton_2.grid(row=3, column=6, columnspan=2, sticky="NSEW")
smman.grid(row=3, column=0, columnspan=2, sticky="NSEW")
smauto.grid(row=4, column=0, columnspan=2, sticky="NSEW")
 
 
syst.grid(row=1, column=0, columnspan=2, sticky="NSEW")
weap.grid(row=1, column=2, columnspan=2, sticky="NSEW")
iff.grid(row=1, column=4, columnspan=2, sticky="NSEW")
test.grid(row=1, column=6, columnspan=2, sticky="NSEW")
target.grid(row=6, column=0, columnspan=3, sticky="NSEW")
spectral.grid(row=6, column=3, columnspan=2, sticky="NSEW")
ts.grid(row=6, column=5, columnspan=3, sticky="NSEW")
 
group1 = deque((button_1, smman, smauto))
group2 = deque((wsbutton_1, wsbutton_2))
group3 = deque((isbutton_1, isbutton_2, isbutton_3, isbutton_4))
group4 = deque((trbutton_1, trbutton_2))
group5 = deque((button_4, button_3, button_2))
group6 = deque((sbutton_1, sbutton_2))
group7 = deque((tsbutton_1, tsbutton_2, tsbutton_3))
header_group = deque(((syst, group1), (weap, group2),
                     (iff, group3), (test, group4),
                     (target, group5), (spectral, group6),
                     (ts, group7)))
 
 
def toggle_button_group(button_group):
    button_group[0].config(
        foreground='black', background='yellow', relief='sunken')
    for button in islice(button_group, 1, None):
        button.config(foreground='yellow', background='black', relief='raised')
 
 
def toggle_header_group(header_group):
    header_group[0][0].config(
        disabledforeground='black', background='yellow', relief='sunken')
    for button in islice(header_group, 1, None):
        button[0].config(disabledforeground='yellow',
                         background='black', relief='raised')
 
 
def start_with_first_selected(first_selected=False):
    if first_selected:
        toggle_button_group(group1)
        toggle_button_group(group2)
        toggle_button_group(group3)
        toggle_button_group(group4)
        toggle_button_group(group5)
        toggle_button_group(group6)
        toggle_button_group(group7)
    else:
        # set last of each group to selected
        group1.rotate(1)
        group2.rotate(1)
        group3.rotate(1)
        group4.rotate(1)
        group5.rotate(1)
        group6.rotate(1)
        group7.rotate(1)
 
 
start_with_first_selected(False)
toggle_header_group(header_group)
 
 
def on_down(event):
    group = header_group[0][1]
    group.rotate(-1)
    toggle_button_group(group)
 
 
def on_up(event):
    group = header_group[0][1]
    group.rotate(1)
    toggle_button_group(group)
 
 
def on_left(event):
    header_group.rotate(1)
    toggle_header_group(header_group)
 
 
def on_right(event):
    header_group.rotate(-1)
    toggle_header_group(header_group)
 
 
root.bind('<Down>', on_down)
root.bind('<Up>', on_up)
root.bind('<Left>', on_left)
root.bind('<Right>', on_right)

root.mainloop()

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Apr 18, 2021 2:00 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
This is the logic addressed with bars and overheat/ammo low messages

Code:
import tkinter as tk
from tkinter import messagebox
import datetime as dt
import tkinter.ttk as ttk
import time

# sets ammo count to initial value of 500
INITIAL_COUNTER_VALUE = 500
# sets initial time at 100%
INITIAL_TIMER_VALUE = 33000
# sets initial gun terminal ID
#sets gun rate
RMMAX = 0
# sets initial temparature
TEMP_INITIAL = 20
# sets text string for ammo/temp/low ammo status button
STATUS = ""

COOLED = 20
 
class TkApp(tk.Tk):
#class MainFrame(tk.Frame):
 
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # set screen options
        self.geometry("640x400")
        self.configure(bg='black')
        self.title("Sentry Terminal")
        # locally initialize ammo count down
        self.counter = tk.IntVar()
        self.counter.set(INITIAL_COUNTER_VALUE)
        # locally sets the timer count down at 100%
        self.timer = tk.IntVar()
        self.timer.set(INITIAL_TIMER_VALUE)
        # locally sets rmbar to 0%
        self.rmcount = tk.IntVar()
        self.rmcount.set(RMMAX)
        # locally sets tempbar
        self.temperature = tk.IntVar()
        self.temperature.set(TEMP_INITIAL)
        # locally sets text string for ammo status button
        self.stat = tk.StringVar()
        self.stat.set(STATUS)
#
        self.cooldown = tk.IntVar()
        self.stat.set(COOLED)


        tk.Grid.rowconfigure(self, 0, weight=1, uniform='c')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 3, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 4, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 5, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 6, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 7, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 8, weight=1, uniform='b')

        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 3, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 4, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 5, weight=1, uniform='a')


 
# key input bindings
        self.bind("<KeyPress-f>", self.on_keypress_f)
        self.bind("<KeyRelease-f>", self.on_keyrelease_f)
        # these are the button and label declarations
        rounds = tk.Label(self, justify=tk.CENTER, textvariable=self.counter)
        rounds.grid(row=3, column=2, columnspan=1, sticky="EW")
        label1 = tk.Label(self, textvariable=self.timer)
        label1.grid(row=7, column=2, sticky="EW")
        # declarative buttons
        timestat = tk.Button(self,bg='black',state=tk.DISABLED, fg='yellow',disabledforeground='yellow',highlightbackground='yellow',borderwidth=2,justify=tk.CENTER,text="TIME AT 100% \n (msecs)")
        timestat.grid(row=7,column=0,columnspan=2,sticky="NSEW")
        roundsr = tk.Button(self,bg='black',state=tk.DISABLED, fg='yellow',disabledforeground='yellow',highlightbackground='yellow',borderwidth=2,justify=tk.CENTER,text="Rounds \n Remaining")
        roundsr.grid(row=3,column=0,columnspan=2,sticky="NS")




        temp = tk.Button(self,justify=tk.CENTER,text="Temp",bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        temp.grid(row=2,column=4,sticky="NSEW")

        rm = tk.Button(self,justify=tk.CENTER,text="R(M)",bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        rm.grid(row=2,column=5,sticky="NSEW")
        # rounds rate bar
        rmbar = ttk.Progressbar(self, orient="vertical", variable=self.rmcount)
        rmbar.grid(row=3,column=5,rowspan=6, sticky="NS")

        # temperature bar
        tempbar = ttk.Progressbar(self, orient="vertical", variable=self.temperature)
        tempbar.grid(row=3,column=4,rowspan=6,sticky="NS")

        # crit menu bar
        crit = tk.Label(self,justify=tk.CENTER, textvariable=self.stat, bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        crit.grid(row=5,column=0,columnspan=2,sticky="NSEW")

# these are ported
    def coolbar(self):
        temperature_count = self.temperature.get()
        if temperature_count >= 21:
          temperature_count = self.temperature.get()
          temperature_count = temperature_count-1 or TEMP_INITIAL     
          self.temperature.set(temperature_count)
          print("key not pressed", temperature_count)
          self.after(300, self.coolbar)

    def overheat(self):
        rmcount_count = self.rmcount.get()
        rmcount_count = 0
        self.rmcount.set(rmcount_count)
        state_stat = self.stat.get()
        state_stat = "OVERHEAT"
        self.stat.set(state_stat)
        time.sleep(0.7)
       



    def on_keypress_f(self, evet):       
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)
        counter_value = self.counter.get()
        # this is logic to try and get ammo warnings


        if counter_value <= 50 >= 2:
          counter_value = self.counter.get()
          state_stat = self.stat.get()
          state_stat = "CRITICAL"
          self.stat.set(state_stat)
          counter_value = self.counter.get()
          print("ammo CRIT", counter_value)
        if counter_value == 1:
          counter_value = self.counter.get()
          state_stat = self.stat.get()
          state_stat = "OUT"
          self.stat.set(state_stat)
          counter_value = self.counter.get()         
          print("out of ammo", counter_value)
        # this sets the time at 100%
        timer_value = self.timer.get()
        timer_value = timer_value-66 or INITIAL_TIMER_VALUE
        self.timer.set(timer_value)
        # this sets the rmbar to 40%
        rmcount_count = self.rmcount.get()
        rmcount_count = 40
        self.rmcount.set(rmcount_count)
        # this sets the temperature
        temperature_count =  self.temperature.get()
        temperature_count = temperature_count+1
        self.temperature.set(temperature_count)
        if temperature_count == 90:
          self.coolbar()
          self.overheat()
        else:
          state_stat = self.stat.get()
          state_stat = ""
          self.stat.set(state_stat)
         
    def on_keyrelease_f(self, evet):
        #this adds logic to say rate is zero if not firing
        #this automatically turns off rate bar moment key is released fixing a logic issue
        rmcount_count = self.rmcount.get()
        rmcount_count = 0
        self.rmcount.set(rmcount_count)
        temperature_count =  self.temperature.get()
        if temperature_count >= 20:
          self.coolbar()
 #       elif temperature_count == 20:
  #        pass

tk_app = TkApp()
tk_app.mainloop()

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Apr 18, 2021 12:00 pm 

Service Number: A05/TQ2.0.32141E1
Country: United States
I am still hashing out logic issues. Everything still more or less works. Right now I am fighting with the select menu getting it rewritten to work with the splash menu setup.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Apr 18, 2021 9:07 pm 

Service Number: A05/TQ2.0.32141E1
Country: United States
select screen is rewritten to port directly into the splash screen.

Code:

from collections import deque
from itertools import islice
from tkinter import *
import tkinter
import tkinter.ttk as ttk
import tkinter as tk
import time
from threading import Thread
GUN = ""



class TkApp(tk.Tk):
    # these arguments initialize the class and how to form arguments within
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # Adjust size
        self.geometry("640x400")
        self.configure(bg='black')
        self.gun = tk.StringVar()
        self.gun.set(GUN)
        # Specify Grid
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 3, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 4, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 5, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 6, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 7, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 8, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 9, weight=1, uniform='b')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 3, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 4, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 5, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 6, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 7, weight=1, uniform='d')
        button_1 = tk.Button(self, justify=tk.CENTER, text="AUTO-REMOTE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_2 = tk.Button(self, justify=tk.CENTER, text="HARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_3 = tk.Button(self, justify=tk.CENTER, text="SEMIHARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_4 = tk.Button(self, justify=tk.CENTER, text="SOFT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_1 = tk.Button(self, justify=tk.CENTER, text="BIO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_2 = tk.Button(self, justify=tk.CENTER, text="INERT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_1 = tk.Button(self, justify=tk.CENTER, text="MULTI SPEC", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_2 = tk.Button(self, justify=tk.CENTER, text="INFRA RED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_3 = tk.Button(self, justify=tk.CENTER, text="UV", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_1 = tk.Button(self, justify=tk.CENTER, text="SAFE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_2 = tk.Button(self, justify=tk.CENTER, text="ARMED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_1 = tk.Button(self, justify=tk.CENTER, text="SEARCH", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_2 = tk.Button(self, justify=tk.CENTER, text="TEST", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_3 = tk.Button(self, justify=tk.CENTER, text="ENGAGED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_4 = tk.Button(self, justify=tk.CENTER, text="INTERROGATE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_1 = tk.Button(self, justify=tk.CENTER, text="AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_2 = tk.Button(self, justify=tk.CENTER, text="SELECTIVE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smman = tk.Button(self, justify=tk.CENTER, text="MAN-OVERRIDE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smauto = tk.Button(self, justify=tk.CENTER, text="SEMI-AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        # displays gun id on top left and right of screen
        gun_1 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun, highlightcolor = 'yellow')
        gun_2 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun)
        headernew = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="UA         571-C \n REMOTE SENTRY WEAPON SYSTEM")
        syst = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SYSTEM \n   MODE")
        weap = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="WEAPON \n   STATUS")
        iff = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="IFF \n   STATUS")
        test = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TEST \n   ROUTINE")
        target = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET PROFILE")
        spectral = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SPECTRAL PROFILE")
        ts = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET SELECT")
        gun_1.grid(row=0, column=0, ipadx=2, ipady=2, padx=2, pady=2, sticky=W)
        gun_2.grid(row=0, column=7, ipadx=2, ipady=2, padx=2, pady=2, sticky=E)
        headernew.grid(row=0, column=1, columnspan=6, sticky="NSEW")
        button_1.grid(row=2, column=0, columnspan=2, sticky="NSEW")
        button_2.grid(row=9, column=0, columnspan=3, sticky="NSEW")
        button_3.grid(row=8, column=0, columnspan=3, sticky="NSEW")
        button_4.grid(row=7, column=0, columnspan=3, sticky="NSEW")
        sbutton_1.grid(row=7, column=3, columnspan=2, sticky="NSEW")
        sbutton_2.grid(row=8, column=3, columnspan=2, sticky="NSEW")
        tsbutton_1.grid(row=7, column=5, columnspan=3, sticky="NSEW")
        tsbutton_2.grid(row=8, column=5, columnspan=3, sticky="NSEW")
        tsbutton_3.grid(row=9, column=5, columnspan=3, sticky="NSEW")
        wsbutton_1.grid(row=2, column=2, columnspan=2, sticky="NSEW")
        wsbutton_2.grid(row=3, column=2, columnspan=2, sticky="NSEW")
        isbutton_1.grid(row=2, column=4, columnspan=2, sticky="NSEW")
        isbutton_2.grid(row=3, column=4, columnspan=2, sticky="NSEW")
        isbutton_3.grid(row=4, column=4, columnspan=2, sticky="NSEW")
        isbutton_4.grid(row=5, column=4, columnspan=2, sticky="NSEW")
        trbutton_1.grid(row=2, column=6, columnspan=2, sticky="NSEW")
        trbutton_2.grid(row=3, column=6, columnspan=2, sticky="NSEW")
        smman.grid(row=3, column=0, columnspan=2, sticky="NSEW")
        smauto.grid(row=4, column=0, columnspan=2, sticky="NSEW")
        syst.grid(row=1, column=0, columnspan=2, sticky="NSEW")
        weap.grid(row=1, column=2, columnspan=2, sticky="NSEW")
        iff.grid(row=1, column=4, columnspan=2, sticky="NSEW")
        test.grid(row=1, column=6, columnspan=2, sticky="NSEW")
        target.grid(row=6, column=0, columnspan=3, sticky="NSEW")
        spectral.grid(row=6, column=3, columnspan=2, sticky="NSEW")
        ts.grid(row=6, column=5, columnspan=3, sticky="NSEW")
        # this quits by clicking a button labeled q
        quit = tk.Button(self, bg='black', fg='yellow', text='q', command=self.quit)
        quit.grid(row=8,column=0,sticky="SW")
        self.bind('<KeyPress-Down>', self.on_down)
        self.bind("<Up>", self.on_up)
        self.bind("<Left>", self.on_left)
        self.bind("<Right>", self.on_right)
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.group1 = deque((button_1, smman, smauto))
        self.group2 = deque((wsbutton_1, wsbutton_2))
        self.group3 = deque((isbutton_1, isbutton_2, isbutton_3, isbutton_4))
        self.group4 = deque((trbutton_1, trbutton_2))
        self.group5 = deque((button_4, button_3, button_2))
        self.group6 = deque((sbutton_1, sbutton_2))
        self.group7 = deque((tsbutton_1, tsbutton_2, tsbutton_3))
        self.header_group = deque(((syst, self.group1), (weap, self.group2),(iff, self.group3), (test, self.group4),(target, self.group5), (spectral, self.group6),(ts, self.group7)))
        self.start_with_first_selected(False)
        self.toggle_header_group(self.header_group)
 
    def toggle_button_group(self, button_group):
        button_group[0].config(foreground='black', background='yellow', relief='sunken')
        for button in islice(button_group, 1, None):
            button.config(foreground='yellow', background='black', relief='raised')
 
    def toggle_header_group(self, header_group):
        header_group[0][0].config(disabledforeground='black', background='yellow', relief='sunken')
        for button in islice(self.header_group, 1, None):
            button[0].config(disabledforeground='yellow',background='black', relief='raised')
 
    def start_with_first_selected(self, first_selected=False):
        if first_selected:
           toggle_button_group(self.group1)
           toggle_button_group(self.group2)
           toggle_button_group(self.group3)
           toggle_button_group(self.group4)
           toggle_button_group(self.group5)
           toggle_button_group(self.group6)
           toggle_button_group(self.group7)
        else:
        # set last of each group to selected
           self.group1.rotate(1)
           self.group2.rotate(1)
           self.group3.rotate(1)
           self.group4.rotate(1)
           self.group5.rotate(1)
           self.group6.rotate(1)
           self.group7.rotate(1)
         
    def on_down(self, evet):
       group = self.header_group[0][1]
       group.rotate(-1)
       self.toggle_button_group(group)
 
    def on_up(self, evet):
       group = self.header_group[0][1]
       group.rotate(1)
       self.toggle_button_group(group)
 
    def on_left(self, evet):
       self.header_group.rotate(1)
       self.toggle_header_group(self.header_group)
 
    def on_right(self, evet):
       self.header_group.rotate(-1)
       self.toggle_header_group(self.header_group)

    # these work
    def on_keypress_a(self, evet):
        which_gun = self.gun.get()
        which_gun = "A"
        self.gun.set(which_gun)
    def on_keypress_b(self, evet):
        which_gun = self.gun.get()
        which_gun = "B"
        self.gun.set(which_gun)
    def on_keypress_c(self, evet):
        which_gun = self.gun.get()
        which_gun = "C"
        self.gun.set(which_gun)
    def on_keypress_d(self, evet):
        which_gun = self.gun.get()
        which_gun = "D"
        self.gun.set(which_gun)
    # this reloads the window, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()
    # this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()
 

# this executes the main loop and tkinter self delcared class.  It declares the function then runs it in the main loop.
tk_app = TkApp()

tk_app.mainloop()


_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 19, 2021 12:04 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
I got the selection screen added in. Kudos screen is more or less done as well.

Code:
import tkinter as tk
from tkinter import *
#import PIL.ImageTk
#import image
#import PIL
#import PIL.Image
import tkinter.ttk as ttk
import datetime as dt
import time
import os
from tkinter import messagebox
from collections import deque
from itertools import islice
from threading import Thread
#
# global variables will be declared here
GUN = ""


# end global variables section
#
# This is the initial screen that loads and then disappears after 8 seconds
# I used 3 images to make the main deal.  The issue was that pygame allowed for line draws
# tkinter only allows for drawing of boxes. 
# should this change I will change from using images.
class SplashFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Iniitaling")
        self.img = tk.PhotoImage(file='load5.png')
        self.configure(background='black')
        self.overrideredirect(True)
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='a')
        self.leftimage = PhotoImage(file='loadleft22.png')
        left = ttk.Label(self, style="TLabel", image=self.leftimage)
        left.grid(row=2, column=0, sticky="NSEW")
        self.rightimage = PhotoImage(file='loadright3.png')
        right = ttk.Label(self, style="TLabel", image=self.rightimage)
        right.grid(row=2, column=2, sticky="NSEW")
        btn = tk.Label(self, image=self.img)
        btn.grid(row=0, rowspan=2, column=0, columnspan=3, sticky="NSEW")
        styled = ttk.Style()
        styled.theme_use('clam')
        styled.configure("TLabel", background='black', darkcolor='black', bordercolor='black', relief='none', lightcolor='black', highlightcolor='black', foreground='black', shiftrelief=-5, highlightthickness=0, width=0, anchor="NSEW")
        styled.configure("Horizontal.TProgressbar", foreground = 'black', background = 'yellow', bordercolor='black', darkcolor='black', throughcolor='black', lightcolor='black')
        loadingbar = ttk.Progressbar(self, style="Horizontal.TProgressbar", orient="horizontal", length = 200, mode='indeterminate', maximum=100)
        loadingbar.grid(row=2, column=1, sticky="NEW")
        loadingbar.start([78])
        self.overrideredirect(True)
# self.after has a timer in msecs.  Just change this to your desired value.  I have logic on loading bar set for 8 seconds so if you change that
# you will need to adjust the loadingbar.start number.  Remember it is 200 units long and you divide that by the time in msecs to figure out how to divide up the movement
        self.after(1000, self.destroy)
#
# End of splash screen defined class and related functions
#




#------------begin select screen------------------------------
# Begin select menu defined class and related functions
# This is the script's core window so more code will be present here than in other sections

# This is the next screen to load after the initial splash screen
class TkApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Select Screen")
        self.configure(bg='black')
        self.gun = tk.StringVar()
        self.gun.set(GUN)
        # Specify Grid
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 3, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 4, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 5, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 6, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 7, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 8, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 9, weight=1, uniform='b')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 3, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 4, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 5, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 6, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 7, weight=1, uniform='d')


        button_1 = tk.Button(self, justify=tk.CENTER, text="AUTO-REMOTE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_2 = tk.Button(self, justify=tk.CENTER, text="HARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_3 = tk.Button(self, justify=tk.CENTER, text="SEMIHARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_4 = tk.Button(self, justify=tk.CENTER, text="SOFT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_1 = tk.Button(self, justify=tk.CENTER, text="BIO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_2 = tk.Button(self, justify=tk.CENTER, text="INERT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_1 = tk.Button(self, justify=tk.CENTER, text="MULTI SPEC", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_2 = tk.Button(self, justify=tk.CENTER, text="INFRA RED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_3 = tk.Button(self, justify=tk.CENTER, text="UV", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_1 = tk.Button(self, justify=tk.CENTER, text="SAFE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_2 = tk.Button(self, justify=tk.CENTER, text="ARMED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_1 = tk.Button(self, justify=tk.CENTER, text="SEARCH", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_2 = tk.Button(self, justify=tk.CENTER, text="TEST", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_3 = tk.Button(self, justify=tk.CENTER, text="ENGAGED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_4 = tk.Button(self, justify=tk.CENTER, text="INTERROGATE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_1 = tk.Button(self, justify=tk.CENTER, text="AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_2 = tk.Button(self, justify=tk.CENTER, text="SELECTIVE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smman = tk.Button(self, justify=tk.CENTER, text="MAN-OVERRIDE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smauto = tk.Button(self, justify=tk.CENTER, text="SEMI-AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        # displays gun id on top left and right of screen
        gun_1 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun, highlightcolor = 'yellow')
        gun_2 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun)
        headernew = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="UA         571-C \n REMOTE SENTRY WEAPON SYSTEM")
        syst = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SYSTEM \n   MODE")
        weap = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="WEAPON \n   STATUS")
        iff = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="IFF \n   STATUS")
        test = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TEST \n   ROUTINE")
        target = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET PROFILE")
        spectral = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SPECTRAL PROFILE")
        ts = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET SELECT")
        gun_1.grid(row=0, column=0, ipadx=2, ipady=2, padx=2, pady=2, sticky=W)
        gun_2.grid(row=0, column=7, ipadx=2, ipady=2, padx=2, pady=2, sticky=E)
        headernew.grid(row=0, column=1, columnspan=6, sticky="NSEW")
        button_1.grid(row=2, column=0, columnspan=2, sticky="NSEW")
        button_2.grid(row=9, column=0, columnspan=3, sticky="NSEW")
        button_3.grid(row=8, column=0, columnspan=3, sticky="NSEW")
        button_4.grid(row=7, column=0, columnspan=3, sticky="NSEW")
        sbutton_1.grid(row=7, column=3, columnspan=2, sticky="NSEW")
        sbutton_2.grid(row=8, column=3, columnspan=2, sticky="NSEW")
        tsbutton_1.grid(row=7, column=5, columnspan=3, sticky="NSEW")
        tsbutton_2.grid(row=8, column=5, columnspan=3, sticky="NSEW")
        tsbutton_3.grid(row=9, column=5, columnspan=3, sticky="NSEW")
        wsbutton_1.grid(row=2, column=2, columnspan=2, sticky="NSEW")
        wsbutton_2.grid(row=3, column=2, columnspan=2, sticky="NSEW")
        isbutton_1.grid(row=2, column=4, columnspan=2, sticky="NSEW")
        isbutton_2.grid(row=3, column=4, columnspan=2, sticky="NSEW")
        isbutton_3.grid(row=4, column=4, columnspan=2, sticky="NSEW")
        isbutton_4.grid(row=5, column=4, columnspan=2, sticky="NSEW")
        trbutton_1.grid(row=2, column=6, columnspan=2, sticky="NSEW")
        trbutton_2.grid(row=3, column=6, columnspan=2, sticky="NSEW")
        smman.grid(row=3, column=0, columnspan=2, sticky="NSEW")
        smauto.grid(row=4, column=0, columnspan=2, sticky="NSEW")
        syst.grid(row=1, column=0, columnspan=2, sticky="NSEW")
        weap.grid(row=1, column=2, columnspan=2, sticky="NSEW")
        iff.grid(row=1, column=4, columnspan=2, sticky="NSEW")
        test.grid(row=1, column=6, columnspan=2, sticky="NSEW")
        target.grid(row=6, column=0, columnspan=3, sticky="NSEW")
        spectral.grid(row=6, column=3, columnspan=2, sticky="NSEW")
        ts.grid(row=6, column=5, columnspan=3, sticky="NSEW")
        # this quits by clicking a button labeled q
        quit = tk.Button(self, bg='black', fg='yellow', text='q', command=self.quit)
        quit.grid(row=8,column=0,sticky="SW")
        self.bind('<KeyPress-Down>', self.on_down)
        self.bind("<Up>", self.on_up)
        self.bind("<Left>", self.on_left)
        self.bind("<Right>", self.on_right)
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        tk.Button(self, text='SecondFrame', command=self.on_button, bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow').grid(row=9, column=0, sticky="SW")
        self.create_splashframe()
        # These are the bind key definitions
        self.bind("<KeyPress-r>", self.on_keypress_r)

        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
        self.group1 = deque((button_1, smman, smauto))
        self.group2 = deque((wsbutton_1, wsbutton_2))
        self.group3 = deque((isbutton_1, isbutton_2, isbutton_3, isbutton_4))
        self.group4 = deque((trbutton_1, trbutton_2))
        self.group5 = deque((button_4, button_3, button_2))
        self.group6 = deque((sbutton_1, sbutton_2))
        self.group7 = deque((tsbutton_1, tsbutton_2, tsbutton_3))
        self.header_group = deque(((syst, self.group1), (weap, self.group2),(iff, self.group3), (test, self.group4),(target, self.group5), (spectral, self.group6),(ts, self.group7)))
        self.start_with_first_selected(False)
        self.toggle_header_group(self.header_group)
 
    def toggle_button_group(self, button_group):
        button_group[0].config(foreground='black', background='yellow', relief='sunken')
        for button in islice(button_group, 1, None):
            button.config(foreground='yellow', background='black', relief='raised')
 
 
    def toggle_header_group(self, header_group):
        header_group[0][0].config(disabledforeground='black', background='yellow', relief='sunken')
        for button in islice(self.header_group, 1, None):
            button[0].config(disabledforeground='yellow',background='black', relief='raised')
 
 
    def start_with_first_selected(self, first_selected=False):
        if first_selected:
           toggle_button_group(self.group1)
           toggle_button_group(self.group2)
           toggle_button_group(self.group3)
           toggle_button_group(self.group4)
           toggle_button_group(self.group5)
           toggle_button_group(self.group6)
           toggle_button_group(self.group7)
        else:
        # set last of each group to selected
           self.group1.rotate(1)
           self.group2.rotate(1)
           self.group3.rotate(1)
           self.group4.rotate(1)
           self.group5.rotate(1)
           self.group6.rotate(1)
           self.group7.rotate(1)
       

 
    def on_down(self, evet):
       group = self.header_group[0][1]
       group.rotate(-1)
       self.toggle_button_group(group)
 
    def on_up(self, evet):
       group = self.header_group[0][1]
       group.rotate(1)
       self.toggle_button_group(group)
 
    def on_left(self, evet):
       self.header_group.rotate(1)
       self.toggle_header_group(self.header_group)
 
    def on_right(self, evet):
       self.header_group.rotate(-1)
       self.toggle_header_group(self.header_group)





 # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()
# this launches the next screen, the fire select screen
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()

    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()

    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
    # these work
    def on_keypress_a(self, evet):
        which_gun = self.gun.get()
        which_gun = "A"
        self.gun.set(which_gun)
    def on_keypress_b(self, evet):
        which_gun = self.gun.get()
        which_gun = "B"
        self.gun.set(which_gun)
    def on_keypress_c(self, evet):
        which_gun = self.gun.get()
        which_gun = "C"
        self.gun.set(which_gun)
    def on_keypress_d(self, evet):
        which_gun = self.gun.get()
        which_gun = "D"
        self.gun.set(which_gun)

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()
# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()

#
#
#
#
# this is the third fire screen
class SecondFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Fire status screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Button(self, text='Close', command=self.destroy).grid(row=0, column=0, sticky="NSEW")
        # These are the bind key definitions
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)


 # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()
# this launches the next screen, the fire select screen
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()



    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.create_splashframe

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.destroy()
        self.quit()






#
#
# End fire menu class and related functions
#
#
#Begin secret credits(kudos) screen
#
#

class KudosFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Secret credits screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')

        r0c0 = tk.Button(self, text='Close', command=self.destroy, bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r0c0.grid(row=0, column=0, sticky="NSEW")
        r1c0 = tk.Label(self, text ='Alienslegacy.com Credits \n knoxvilles_joker aka gabriel vos new script  \n martinr1000 font and some coding help \n MLR 2007 for original flash script \n Facebook.com  theuscm \n youtube.com/channel/UC4KYYScA5WcdCZeiU6lcjdA \n cobra_shipwreck channel aka knoxvilles_joker', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r1c0.grid(row=1, column=0, sticky="NSEW")
        r1c1 = tk.Label(self, text =' ', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r1c1.grid(row=1, column=1, sticky="NSEW")
        r0c1 = tk.Label(self, text ='Python-forum.io credits \n Yoriz coding pointers and help \n ndc85430 coding critique \n ', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r0c1.grid(row=0, column=1, sticky="NSEW")

        # These are the bind key definitions

        self.bind("<KeyPress-r>", self.on_keypress_r)

        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
        self.bind("<KeyPress-q>", self.on_keypress_q)

    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()
    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()
    # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()


# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
         
        self.create_splashframe # this appears to launch the initial window
       


    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()


# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.destroy()
        self.quit()



#
# End secret credits(kudos) screen
#
#
#
# The below two commands run the entire script

tk_app = TkApp()
tk_app.mainloop()


Logic is good enough I think. Some hardcore programmers may have some tweaks to suggest to improve things.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 19, 2021 12:20 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
These are the 3 files used for the loading screen. I will have another post with sound files once I get that function programmed in.

load5.png
load5.png [ 3.42 KiB | Viewed 71 times ]

loadright3.png
loadright3.png [ 867 Bytes | Viewed 71 times ]

loadleft22.png
loadleft22.png [ 826 Bytes | Viewed 71 times ]


_________________
The impossible takes a while longer and goes over budget too...
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 19, 2021 12:36 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
These are the warning and click sounds and are aptly titled as such.

warning.mp3 [1.12 KiB]
Downloaded 2 times

click.mp3 [423 Bytes]
Downloaded 2 times


_________________
The impossible takes a while longer and goes over budget too...
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 19, 2021 1:04 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
I had to bump the rate to 22khz.

I am still stuck trying to sort out logic on the fire screen for the Critical, out, and overheat loops.

There is the splash screen, the select screen, and the credit(kudos) screen.

Code:
import tkinter as tk
from tkinter import *
#import PIL.ImageTk
#import image
#import PIL
#import PIL.Image
import tkinter.ttk as ttk
import datetime as dt
import time
import os
from tkinter import messagebox
from collections import deque
from itertools import islice
from threading import Thread
from playsound import playsound

#
# global variables will be declared here
GUN = ""


# end global variables section
#
# This is the initial screen that loads and then disappears after 8 seconds
# I used 3 images to make the main deal.  The issue was that pygame allowed for line draws
# tkinter only allows for drawing of boxes. 
# should this change I will change from using images.
class SplashFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Iniitaling")
        self.img = tk.PhotoImage(file='load5.png')
        self.configure(background='black')
        self.overrideredirect(True)
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='a')
        self.leftimage = PhotoImage(file='loadleft22.png')
        left = ttk.Label(self, style="TLabel", image=self.leftimage)
        left.grid(row=2, column=0, sticky="NSEW")
        self.rightimage = PhotoImage(file='loadright3.png')
        right = ttk.Label(self, style="TLabel", image=self.rightimage)
        right.grid(row=2, column=2, sticky="NSEW")
        btn = tk.Label(self, image=self.img)
        btn.grid(row=0, rowspan=2, column=0, columnspan=3, sticky="NSEW")
        styled = ttk.Style()
        styled.theme_use('clam')
        styled.configure("TLabel", background='black', darkcolor='black', bordercolor='black', relief='none', lightcolor='black', highlightcolor='black', foreground='black', shiftrelief=-5, highlightthickness=0, width=0, anchor="NSEW")
        styled.configure("Horizontal.TProgressbar", foreground = 'black', background = 'yellow', bordercolor='black', darkcolor='black', throughcolor='black', lightcolor='black')
        loadingbar = ttk.Progressbar(self, style="Horizontal.TProgressbar", orient="horizontal", length = 200, mode='indeterminate', maximum=100)
        loadingbar.grid(row=2, column=1, sticky="NEW")
        loadingbar.start([78])
        self.overrideredirect(True)
# self.after has a timer in msecs.  Just change this to your desired value.  I have logic on loading bar set for 8 seconds so if you change that
# you will need to adjust the loadingbar.start number.  Remember it is 200 units long and you divide that by the time in msecs to figure out how to divide up the movement
        self.after(1000, self.destroy)
#
# End of splash screen defined class and related functions
#




#------------begin select screen------------------------------
# Begin select menu defined class and related functions
# This is the script's core window so more code will be present here than in other sections

# This is the next screen to load after the initial splash screen
class TkApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Select Screen")
        self.configure(bg='black')
        self.gun = tk.StringVar()
        self.gun.set(GUN)
        # Specify Grid
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 3, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 4, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 5, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 6, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 7, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 8, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 9, weight=1, uniform='b')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 3, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 4, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 5, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 6, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 7, weight=1, uniform='d')


        button_1 = tk.Button(self, justify=tk.CENTER, text="AUTO-REMOTE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_2 = tk.Button(self, justify=tk.CENTER, text="HARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_3 = tk.Button(self, justify=tk.CENTER, text="SEMIHARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_4 = tk.Button(self, justify=tk.CENTER, text="SOFT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_1 = tk.Button(self, justify=tk.CENTER, text="BIO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_2 = tk.Button(self, justify=tk.CENTER, text="INERT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_1 = tk.Button(self, justify=tk.CENTER, text="MULTI SPEC", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_2 = tk.Button(self, justify=tk.CENTER, text="INFRA RED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_3 = tk.Button(self, justify=tk.CENTER, text="UV", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_1 = tk.Button(self, justify=tk.CENTER, text="SAFE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_2 = tk.Button(self, justify=tk.CENTER, text="ARMED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_1 = tk.Button(self, justify=tk.CENTER, text="SEARCH", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_2 = tk.Button(self, justify=tk.CENTER, text="TEST", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_3 = tk.Button(self, justify=tk.CENTER, text="ENGAGED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_4 = tk.Button(self, justify=tk.CENTER, text="INTERROGATE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_1 = tk.Button(self, justify=tk.CENTER, text="AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_2 = tk.Button(self, justify=tk.CENTER, text="SELECTIVE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smman = tk.Button(self, justify=tk.CENTER, text="MAN-OVERRIDE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smauto = tk.Button(self, justify=tk.CENTER, text="SEMI-AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        # displays gun id on top left and right of screen
        gun_1 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun, highlightcolor = 'yellow')
        gun_2 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun)
        headernew = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="UA         571-C \n REMOTE SENTRY WEAPON SYSTEM")
        syst = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SYSTEM \n   MODE")
        weap = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="WEAPON \n   STATUS")
        iff = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="IFF \n   STATUS")
        test = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TEST \n   ROUTINE")
        target = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET PROFILE")
        spectral = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SPECTRAL PROFILE")
        ts = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET SELECT")
        gun_1.grid(row=0, column=0, ipadx=2, ipady=2, padx=2, pady=2, sticky=W)
        gun_2.grid(row=0, column=7, ipadx=2, ipady=2, padx=2, pady=2, sticky=E)
        headernew.grid(row=0, column=1, columnspan=6, sticky="NSEW")
        button_1.grid(row=2, column=0, columnspan=2, sticky="NSEW")
        button_2.grid(row=9, column=0, columnspan=3, sticky="NSEW")
        button_3.grid(row=8, column=0, columnspan=3, sticky="NSEW")
        button_4.grid(row=7, column=0, columnspan=3, sticky="NSEW")
        sbutton_1.grid(row=7, column=3, columnspan=2, sticky="NSEW")
        sbutton_2.grid(row=8, column=3, columnspan=2, sticky="NSEW")
        tsbutton_1.grid(row=7, column=5, columnspan=3, sticky="NSEW")
        tsbutton_2.grid(row=8, column=5, columnspan=3, sticky="NSEW")
        tsbutton_3.grid(row=9, column=5, columnspan=3, sticky="NSEW")
        wsbutton_1.grid(row=2, column=2, columnspan=2, sticky="NSEW")
        wsbutton_2.grid(row=3, column=2, columnspan=2, sticky="NSEW")
        isbutton_1.grid(row=2, column=4, columnspan=2, sticky="NSEW")
        isbutton_2.grid(row=3, column=4, columnspan=2, sticky="NSEW")
        isbutton_3.grid(row=4, column=4, columnspan=2, sticky="NSEW")
        isbutton_4.grid(row=5, column=4, columnspan=2, sticky="NSEW")
        trbutton_1.grid(row=2, column=6, columnspan=2, sticky="NSEW")
        trbutton_2.grid(row=3, column=6, columnspan=2, sticky="NSEW")
        smman.grid(row=3, column=0, columnspan=2, sticky="NSEW")
        smauto.grid(row=4, column=0, columnspan=2, sticky="NSEW")
        syst.grid(row=1, column=0, columnspan=2, sticky="NSEW")
        weap.grid(row=1, column=2, columnspan=2, sticky="NSEW")
        iff.grid(row=1, column=4, columnspan=2, sticky="NSEW")
        test.grid(row=1, column=6, columnspan=2, sticky="NSEW")
        target.grid(row=6, column=0, columnspan=3, sticky="NSEW")
        spectral.grid(row=6, column=3, columnspan=2, sticky="NSEW")
        ts.grid(row=6, column=5, columnspan=3, sticky="NSEW")
        # this quits by clicking a button labeled q
        quit = tk.Button(self, bg='black', fg='yellow', text='q', command=self.quit)
        quit.grid(row=8,column=0,sticky="SW")
        self.bind('<KeyPress-Down>', self.on_down)
        self.bind("<Up>", self.on_up)
        self.bind("<Left>", self.on_left)
        self.bind("<Right>", self.on_right)
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        tk.Button(self, text='SecondFrame', command=self.on_button, bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow').grid(row=9, column=0, sticky="SW")
        self.create_splashframe()
        # These are the bind key definitions
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
        self.group1 = deque((button_1, smman, smauto))
        self.group2 = deque((wsbutton_1, wsbutton_2))
        self.group3 = deque((isbutton_1, isbutton_2, isbutton_3, isbutton_4))
        self.group4 = deque((trbutton_1, trbutton_2))
        self.group5 = deque((button_4, button_3, button_2))
        self.group6 = deque((sbutton_1, sbutton_2))
        self.group7 = deque((tsbutton_1, tsbutton_2, tsbutton_3))
        self.header_group = deque(((syst, self.group1), (weap, self.group2),(iff, self.group3), (test, self.group4),(target, self.group5), (spectral, self.group6),(ts, self.group7)))
        self.start_with_first_selected(False)
        self.toggle_header_group(self.header_group)
 
    def toggle_button_group(self, button_group):
        button_group[0].config(foreground='black', background='yellow', relief='sunken')
        for button in islice(button_group, 1, None):
            button.config(foreground='yellow', background='black', relief='raised')
 
 
    def toggle_header_group(self, header_group):
        header_group[0][0].config(disabledforeground='black', background='yellow', relief='sunken')
        for button in islice(self.header_group, 1, None):
            button[0].config(disabledforeground='yellow',background='black', relief='raised')
 
 
    def start_with_first_selected(self, first_selected=False):
        if first_selected:
           toggle_button_group(self.group1)
           toggle_button_group(self.group2)
           toggle_button_group(self.group3)
           toggle_button_group(self.group4)
           toggle_button_group(self.group5)
           toggle_button_group(self.group6)
           toggle_button_group(self.group7)
        else:
        # set last of each group to selected
           self.group1.rotate(1)
           self.group2.rotate(1)
           self.group3.rotate(1)
           self.group4.rotate(1)
           self.group5.rotate(1)
           self.group6.rotate(1)
           self.group7.rotate(1)
       

 
    def on_down(self, evet):
       group = self.header_group[0][1]
       group.rotate(-1)
       self.toggle_button_group(group)
       playsound("click1.mp3")
 
    def on_up(self, evet):
       group = self.header_group[0][1]
       group.rotate(1)
       self.toggle_button_group(group)
       playsound("click1.mp3")
 
    def on_left(self, evet):
       self.header_group.rotate(1)
       self.toggle_header_group(self.header_group)
       playsound("click1.mp3")
 
    def on_right(self, evet):
       self.header_group.rotate(-1)
       self.toggle_header_group(self.header_group)
       playsound("click1.mp3")





 # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()
# this launches the next screen, the fire select screen
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()

    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()

    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
        playsound("click1.mp3")
    # these work
    def on_keypress_a(self, evet):
        which_gun = self.gun.get()
        which_gun = "A"
        self.gun.set(which_gun)
        playsound("click1.mp3")
    def on_keypress_b(self, evet):
        which_gun = self.gun.get()
        which_gun = "B"
        self.gun.set(which_gun)
        playsound("click1.mp3")
    def on_keypress_c(self, evet):
        which_gun = self.gun.get()
        which_gun = "C"
        self.gun.set(which_gun)
        playsound("click1.mp3")
    def on_keypress_d(self, evet):
        which_gun = self.gun.get()
        which_gun = "D"
        self.gun.set(which_gun)
        playsound("click1.mp3")

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
        playsound("click1.mp3")
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()
        playsound("click1.mp3")
# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()
        playsound("click1.mp3")

#
#
#
#
# this is the third fire screen
class SecondFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Fire status screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Button(self, text='Close', command=self.destroy).grid(row=0, column=0, sticky="NSEW")
        # These are the bind key definitions
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)


 # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()
# this launches the next screen, the fire select screen
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()



    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
        playsound("click1.mp3")
# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.create_splashframe
        playsound("click1.mp3")
# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
        playsound("click1.mp3")
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.destroy()
        self.quit()
        playsound("click1.mp3")





#
#
# End fire menu class and related functions
#
#
#Begin secret credits(kudos) screen
#
#

class KudosFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Secret credits screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')

        r0c0 = tk.Button(self, text='Close', command=self.destroy, bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r0c0.grid(row=0, column=0, sticky="NSEW")
        r1c0 = tk.Label(self, text ='Alienslegacy.com Credits \n knoxvilles_joker aka gabriel vos new script  \n martinr1000 font and some coding help \n MLR 2007 for original flash script \n Facebook.com  theuscm \n youtube.com/channel/UC4KYYScA5WcdCZeiU6lcjdA \n cobra_shipwreck channel aka knoxvilles_joker', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r1c0.grid(row=1, column=0, sticky="NSEW")
        r1c1 = tk.Label(self, text =' ', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r1c1.grid(row=1, column=1, sticky="NSEW")
        r0c1 = tk.Label(self, text ='Python-forum.io credits \n Yoriz coding pointers and help \n ndc85430 coding critique \n ', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r0c1.grid(row=0, column=1, sticky="NSEW")

        # These are the bind key definitions

        self.bind("<KeyPress-r>", self.on_keypress_r)

        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
        self.bind("<KeyPress-q>", self.on_keypress_q)

    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()
    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()
    # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()


# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
         
        self.create_splashframe # this appears to launch the initial window
       


    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
        playsound("click1.mp3")

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
        playsound("click1.mp3")
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.destroy()
        self.quit()
        playsound("click1.mp3")



#
# End secret credits(kudos) screen
#
#
#
# The below two commands run the entire script

tk_app = TkApp()
tk_app.mainloop()

click1.mp3 [1.53 KiB]
Downloaded 2 times


_________________
The impossible takes a while longer and goes over budget too...
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 19, 2021 2:14 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
I got the current version of things put together and it runs.

Code:
import tkinter as tk
from tkinter import *
#import PIL.ImageTk
#import image
#import PIL
#import PIL.Image
import tkinter.ttk as ttk
import datetime as dt
import time
import os
from tkinter import messagebox
from collections import deque
from itertools import islice
from threading import Thread
from playsound import playsound

#
# global variables will be declared here
GUN = ""

# sets ammo count to initial value of 500
INITIAL_COUNTER_VALUE = 500
# sets initial time at 100%
INITIAL_TIMER_VALUE = 33000
# sets initial gun terminal ID
#sets gun rate
RMMAX = 0
# sets initial temparature
TEMP_INITIAL = 20
# sets text string for ammo/temp/low ammo status button
STATUS = ""

COOLED = 20

# end global variables section
#
# This is the initial screen that loads and then disappears after 8 seconds
# I used 3 images to make the main deal.  The issue was that pygame allowed for line draws
# tkinter only allows for drawing of boxes. 
# should this change I will change from using images.
class SplashFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Iniitaling")
        self.img = tk.PhotoImage(file='load5.png')
        self.configure(background='black')
        self.overrideredirect(True)
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='a')
        self.leftimage = PhotoImage(file='loadleft22.png')
        left = ttk.Label(self, style="TLabel", image=self.leftimage)
        left.grid(row=2, column=0, sticky="NSEW")
        self.rightimage = PhotoImage(file='loadright3.png')
        right = ttk.Label(self, style="TLabel", image=self.rightimage)
        right.grid(row=2, column=2, sticky="NSEW")
        btn = tk.Label(self, image=self.img)
        btn.grid(row=0, rowspan=2, column=0, columnspan=3, sticky="NSEW")
        styled = ttk.Style()
        styled.theme_use('clam')
        styled.configure("TLabel", background='black', darkcolor='black', bordercolor='black', relief='none', lightcolor='black', highlightcolor='black', foreground='black', shiftrelief=-5, highlightthickness=0, width=0, anchor="NSEW")
        styled.configure("Horizontal.TProgressbar", foreground = 'black', background = 'yellow', bordercolor='black', darkcolor='black', throughcolor='black', lightcolor='black')
        loadingbar = ttk.Progressbar(self, style="Horizontal.TProgressbar", orient="horizontal", length = 200, mode='indeterminate', maximum=100)
        loadingbar.grid(row=2, column=1, sticky="NEW")
        loadingbar.start([78])
        self.overrideredirect(True)
# self.after has a timer in msecs.  Just change this to your desired value.  I have logic on loading bar set for 8 seconds so if you change that
# you will need to adjust the loadingbar.start number.  Remember it is 200 units long and you divide that by the time in msecs to figure out how to divide up the movement
        self.after(1000, self.destroy)
#
# End of splash screen defined class and related functions
#




#------------begin select screen------------------------------
# Begin select menu defined class and related functions
# This is the script's core window so more code will be present here than in other sections

# This is the next screen to load after the initial splash screen
class TkApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Select Screen")
        self.configure(bg='black')
        self.gun = tk.StringVar()
        self.gun.set(GUN)
        # Specify Grid
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 3, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 4, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 5, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 6, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 7, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 8, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 9, weight=1, uniform='b')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 3, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 4, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 5, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 6, weight=1, uniform='d')
        tk.Grid.columnconfigure(self, 7, weight=1, uniform='d')


        button_1 = tk.Button(self, justify=tk.CENTER, text="AUTO-REMOTE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_2 = tk.Button(self, justify=tk.CENTER, text="HARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_3 = tk.Button(self, justify=tk.CENTER, text="SEMIHARD", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        button_4 = tk.Button(self, justify=tk.CENTER, text="SOFT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_1 = tk.Button(self, justify=tk.CENTER, text="BIO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        sbutton_2 = tk.Button(self, justify=tk.CENTER, text="INERT", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_1 = tk.Button(self, justify=tk.CENTER, text="MULTI SPEC", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_2 = tk.Button(self, justify=tk.CENTER, text="INFRA RED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        tsbutton_3 = tk.Button(self, justify=tk.CENTER, text="UV", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_1 = tk.Button(self, justify=tk.CENTER, text="SAFE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        wsbutton_2 = tk.Button(self, justify=tk.CENTER, text="ARMED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_1 = tk.Button(self, justify=tk.CENTER, text="SEARCH", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_2 = tk.Button(self, justify=tk.CENTER, text="TEST", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_3 = tk.Button(self, justify=tk.CENTER, text="ENGAGED", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        isbutton_4 = tk.Button(self, justify=tk.CENTER, text="INTERROGATE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_1 = tk.Button(self, justify=tk.CENTER, text="AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        trbutton_2 = tk.Button(self, justify=tk.CENTER, text="SELECTIVE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smman = tk.Button(self, justify=tk.CENTER, text="MAN-OVERRIDE", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        smauto = tk.Button(self, justify=tk.CENTER, text="SEMI-AUTO", bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        # displays gun id on top left and right of screen
        gun_1 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun, highlightcolor = 'yellow')
        gun_2 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun)
        headernew = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="UA         571-C \n REMOTE SENTRY WEAPON SYSTEM")
        syst = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SYSTEM \n   MODE")
        weap = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="WEAPON \n   STATUS")
        iff = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="IFF \n   STATUS")
        test = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TEST \n   ROUTINE")
        target = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET PROFILE")
        spectral = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="SPECTRAL PROFILE")
        ts = tk.Button(self, bg='black', state=tk.DISABLED, fg='yellow', disabledforeground='yellow',highlightbackground='yellow', borderwidth=2, justify=CENTER, text="TARGET SELECT")
        gun_1.grid(row=0, column=0, ipadx=2, ipady=2, padx=2, pady=2, sticky=W)
        gun_2.grid(row=0, column=7, ipadx=2, ipady=2, padx=2, pady=2, sticky=E)
        headernew.grid(row=0, column=1, columnspan=6, sticky="NSEW")
        button_1.grid(row=2, column=0, columnspan=2, sticky="NSEW")
        button_2.grid(row=9, column=0, columnspan=3, sticky="NSEW")
        button_3.grid(row=8, column=0, columnspan=3, sticky="NSEW")
        button_4.grid(row=7, column=0, columnspan=3, sticky="NSEW")
        sbutton_1.grid(row=7, column=3, columnspan=2, sticky="NSEW")
        sbutton_2.grid(row=8, column=3, columnspan=2, sticky="NSEW")
        tsbutton_1.grid(row=7, column=5, columnspan=3, sticky="NSEW")
        tsbutton_2.grid(row=8, column=5, columnspan=3, sticky="NSEW")
        tsbutton_3.grid(row=9, column=5, columnspan=3, sticky="NSEW")
        wsbutton_1.grid(row=2, column=2, columnspan=2, sticky="NSEW")
        wsbutton_2.grid(row=3, column=2, columnspan=2, sticky="NSEW")
        isbutton_1.grid(row=2, column=4, columnspan=2, sticky="NSEW")
        isbutton_2.grid(row=3, column=4, columnspan=2, sticky="NSEW")
        isbutton_3.grid(row=4, column=4, columnspan=2, sticky="NSEW")
        isbutton_4.grid(row=5, column=4, columnspan=2, sticky="NSEW")
        trbutton_1.grid(row=2, column=6, columnspan=2, sticky="NSEW")
        trbutton_2.grid(row=3, column=6, columnspan=2, sticky="NSEW")
        smman.grid(row=3, column=0, columnspan=2, sticky="NSEW")
        smauto.grid(row=4, column=0, columnspan=2, sticky="NSEW")
        syst.grid(row=1, column=0, columnspan=2, sticky="NSEW")
        weap.grid(row=1, column=2, columnspan=2, sticky="NSEW")
        iff.grid(row=1, column=4, columnspan=2, sticky="NSEW")
        test.grid(row=1, column=6, columnspan=2, sticky="NSEW")
        target.grid(row=6, column=0, columnspan=3, sticky="NSEW")
        spectral.grid(row=6, column=3, columnspan=2, sticky="NSEW")
        ts.grid(row=6, column=5, columnspan=3, sticky="NSEW")
        # this quits by clicking a button labeled q
        quit = tk.Button(self, bg='black', fg='yellow', text='q', command=self.quit)
        quit.grid(row=8,column=0,sticky="SW")
        self.bind('<KeyPress-Down>', self.on_down)
        self.bind("<Up>", self.on_up)
        self.bind("<Left>", self.on_left)
        self.bind("<Right>", self.on_right)
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        tk.Button(self, text='SecondFrame', command=self.on_button, bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow').grid(row=9, column=0, sticky="SW")
        self.create_splashframe()
        # These are the bind key definitions
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
        self.group1 = deque((button_1, smman, smauto))
        self.group2 = deque((wsbutton_1, wsbutton_2))
        self.group3 = deque((isbutton_1, isbutton_2, isbutton_3, isbutton_4))
        self.group4 = deque((trbutton_1, trbutton_2))
        self.group5 = deque((button_4, button_3, button_2))
        self.group6 = deque((sbutton_1, sbutton_2))
        self.group7 = deque((tsbutton_1, tsbutton_2, tsbutton_3))
        self.header_group = deque(((syst, self.group1), (weap, self.group2),(iff, self.group3), (test, self.group4),(target, self.group5), (spectral, self.group6),(ts, self.group7)))
        self.start_with_first_selected(False)
        self.toggle_header_group(self.header_group)
 
    def toggle_button_group(self, button_group):
        button_group[0].config(foreground='black', background='yellow', relief='sunken')
        for button in islice(button_group, 1, None):
            button.config(foreground='yellow', background='black', relief='raised')
 
 
    def toggle_header_group(self, header_group):
        header_group[0][0].config(disabledforeground='black', background='yellow', relief='sunken')
        for button in islice(self.header_group, 1, None):
            button[0].config(disabledforeground='yellow',background='black', relief='raised')
 
 
    def start_with_first_selected(self, first_selected=False):
        if first_selected:
           toggle_button_group(self.group1)
           toggle_button_group(self.group2)
           toggle_button_group(self.group3)
           toggle_button_group(self.group4)
           toggle_button_group(self.group5)
           toggle_button_group(self.group6)
           toggle_button_group(self.group7)
        else:
        # set last of each group to selected
           self.group1.rotate(1)
           self.group2.rotate(1)
           self.group3.rotate(1)
           self.group4.rotate(1)
           self.group5.rotate(1)
           self.group6.rotate(1)
           self.group7.rotate(1)
       

 
    def on_down(self, evet):
       group = self.header_group[0][1]
       group.rotate(-1)
       self.toggle_button_group(group)
       playsound("click1.mp3")
 
    def on_up(self, evet):
       group = self.header_group[0][1]
       group.rotate(1)
       self.toggle_button_group(group)
       playsound("click1.mp3")
 
    def on_left(self, evet):
       self.header_group.rotate(1)
       self.toggle_header_group(self.header_group)
       playsound("click1.mp3")
 
    def on_right(self, evet):
       self.header_group.rotate(-1)
       self.toggle_header_group(self.header_group)
       playsound("click1.mp3")





 # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()
# this launches the next screen, the fire select screen
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()

    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()

    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
        playsound("click1.mp3")
    # these work
    def on_keypress_a(self, evet):
        which_gun = self.gun.get()
        which_gun = "A"
        self.gun.set(which_gun)
        playsound("click1.mp3")
    def on_keypress_b(self, evet):
        which_gun = self.gun.get()
        which_gun = "B"
        self.gun.set(which_gun)
        playsound("click1.mp3")
    def on_keypress_c(self, evet):
        which_gun = self.gun.get()
        which_gun = "C"
        self.gun.set(which_gun)
        playsound("click1.mp3")
    def on_keypress_d(self, evet):
        which_gun = self.gun.get()
        which_gun = "D"
        self.gun.set(which_gun)
        playsound("click1.mp3")

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
        playsound("click1.mp3")
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.quit()
        playsound("click1.mp3")
# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.__init__()
        playsound("click1.mp3")

#
#
#
#
# this is the third fire screen
class SecondFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.configure(bg='black')
        self.title("Fire status screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Button(self, text='Close', command=self.destroy, bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow').grid(row=8, column=1, sticky="NSEW")
         # locally initialize ammo count down
        self.counter = tk.IntVar()
        self.counter.set(INITIAL_COUNTER_VALUE)
        # locally sets the timer count down at 100%
        self.timer = tk.IntVar()
        self.timer.set(INITIAL_TIMER_VALUE)
        # locally sets rmbar to 0%
        self.rmcount = tk.IntVar()
        self.rmcount.set(RMMAX)
        # locally sets tempbar
        self.temperature = tk.IntVar()
        self.temperature.set(TEMP_INITIAL)
        # locally sets text string for ammo status button
        self.stat = tk.StringVar()
        self.stat.set(STATUS)
        #
        self.cooldown = tk.IntVar()
        self.stat.set(COOLED)

        self.gun = tk.StringVar()
        self.gun.set(GUN)

        # this arranges the grid row and column groupings. 
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='c')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 2, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 3, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 4, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 5, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 6, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 7, weight=1, uniform='b')
        tk.Grid.rowconfigure(self, 8, weight=1, uniform='b')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 2, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 3, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 4, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 5, weight=1, uniform='a')
        # these are the button and label declarations
        rounds = tk.Label(self, justify=tk.CENTER, textvariable=self.counter)
        rounds.grid(row=3, column=2, columnspan=1, sticky="EW")
        label1 = tk.Label(self, textvariable=self.timer)
        label1.grid(row=7, column=2, sticky="EW")

        temp = tk.Button(self,justify=tk.CENTER,text="Temp",bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        temp.grid(row=2,column=4,sticky="NSEW")

        rm = tk.Button(self,justify=tk.CENTER,text="R(M)",bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        rm.grid(row=2,column=5,sticky="NSEW")
        # rounds rate bar
        rmbar = ttk.Progressbar(self, orient="vertical", variable=self.rmcount)
        rmbar.grid(row=3,column=5,rowspan=6, sticky="NS")

        # temperature bar
        tempbar = ttk.Progressbar(self, orient="vertical", variable=self.temperature)
        tempbar.grid(row=3,column=4,rowspan=6,sticky="NS")

        # declarative buttons
        timestat = tk.Button(self,bg='black',state=tk.DISABLED, fg='yellow',disabledforeground='yellow',highlightbackground='yellow',borderwidth=2,justify=tk.CENTER,text="TIME AT 100% \n (msecs)")
        timestat.grid(row=7,column=0,columnspan=2,sticky="NSEW")
        roundsr = tk.Button(self,bg='black',state=tk.DISABLED, fg='yellow',disabledforeground='yellow',highlightbackground='yellow',borderwidth=2,justify=tk.CENTER,text="Rounds \n Remaining")
        roundsr.grid(row=3,column=0,columnspan=2,sticky="NS")


        # crit menu bar
        crit = tk.Button(self,justify=tk.CENTER,textvariable=self.stat, bg='black', fg='yellow', highlightbackground='yellow', highlightcolor='black',activebackground='yellow')
        crit.grid(row=5,column=0,columnspan=2,sticky="NSEW")
       

        # static center header
        headernew = tk.Button(self, bg='black',state=tk.DISABLED,justify=tk.CENTER, text="UA 571-C \n REMOTE SENTRY WEAPON SYSTEM")
        headernew.grid(row=0,column=1,columnspan=4,rowspan=2,sticky="NSEW")




        # displays gun id on top left and right of screen
        gun_1 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun, highlightcolor = 'yellow')
        gun_1.grid(row=0,column=0,rowspan=2,sticky="NS")
        gun_2 = tk.Button(self, borderwidth=7,bg='black',fg='yellow',disabledforeground='yellow',state=tk.DISABLED,textvariable=self.gun)
        gun_2.grid(row=0,column=5,rowspan=2,sticky="NS")


        # this quits by clicking a button labeled q
        quit = tk.Button(self, bg='black', fg='yellow', text='q', command=self.quit)
        quit.grid(row=8,column=0,sticky="SW")

        # these are the attachments for input from keyboard into the application
        # These are the button inputs from the original flash app that were used
        # I added a q as well to quit and close window in case there was a need to close

        self.bind("<KeyPress-f>", self.on_keypress_f)
        self.bind("<KeyRelease-f>", self.on_keyrelease_f)
        self.bind("<KeyPress-a>", self.on_keypress_a)
        self.bind("<KeyPress-b>", self.on_keypress_b)
        self.bind("<KeyPress-c>", self.on_keypress_c)
        self.bind("<KeyPress-d>", self.on_keypress_d)
        # These are the bind key definitions
        self.bind("<KeyPress-r>", self.on_keypress_r)
        self.bind("<KeyPress-q>", self.on_keypress_q)
        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
    def coolbar(self):
        temperature_count = self.temperature.get()
        if temperature_count >= 21:
          temperature_count = self.temperature.get()
          temperature_count = temperature_count-1 or TEMP_INITIAL     
          self.temperature.set(temperature_count)
          print("key not pressed", temperature_count)
          self.after(300, self.coolbar)
   

    def overheat(self):
        rmcount_count = self.rmcount.get()
        rmcount_count = 0
        self.rmcount.set(rmcount_count)
        state_stat = self.stat.get()
        state_stat = "OVERHEAT"
        self.stat.set(state_stat)
        playsound("warning1.mp3")
        time.sleep(0.7)

    def critical(self):
        counter_value = self.counter.get()
        if counter_value <= 50:
          counter_value = self.counter.get()
          state_stat = self.stat.get()
          state_stat = "CRITICAL"
          self.stat.set(state_stat)
          playsound("warning1.mp3")
          counter_value = self.counter.get()
          print("ammo CRIT", counter_value)

    def out(self):
        counter_value = self.counter.get()
        if counter_value == 1:
          state_stat = self.stat.get()
          state_stat = "OUT"
          self.stat.set(state_stat)
          playsound("warning1.mp3")
          counter_value = self.counter.get()
          print("ammo CRIT", counter_value)

    def reload(self):
        counter_value = self.counter.get()
        if counter_value >= 1:
          state_stat = self.stat.get()
          state_stat = ""
          self.stat.set(state_stat)
          counter_value = self.counter.get()
          print("ammo CRIT", counter_value)


    # this defines the fire ammo count down sequence and resets
    def on_keypress_f(self, evet):       
        counter_value = self.counter.get()
        counter_value = counter_value-1 or INITIAL_COUNTER_VALUE
        self.counter.set(counter_value)
        counter_value = self.counter.get()
        # this is logic to try and get ammo warnings
        counter_value = self.counter.get()

        self.reload()
        self.critical()
        self.out()

 
        # this sets the time at 100%
        timer_value = self.timer.get()
        timer_value = timer_value-66 or INITIAL_TIMER_VALUE
        self.timer.set(timer_value)
        # this sets the rmbar to 40%
        rmcount_count = self.rmcount.get()
        rmcount_count = 40
        self.rmcount.set(rmcount_count)
        # this sets the temperature
        temperature_count =  self.temperature.get()
        temperature_count = temperature_count+1
        self.temperature.set(temperature_count)
        if temperature_count == 90:
          self.coolbar()
          self.overheat()
        else:
          state_stat = self.stat.get()
          state_stat = ""
          self.stat.set(state_stat)

    def on_keyrelease_f(self, evet):
        #this adds logic to say rate is zero if not firing
        #this automatically turns off rate bar moment key is released fixing a logic issue
        rmcount_count = self.rmcount.get()
        rmcount_count = 0
        self.rmcount.set(rmcount_count)
        temperature_count =  self.temperature.get()
        if temperature_count >= 20:
          self.coolbar()

 # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()
# this launches the next screen, the fire select screen
    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()



    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
        playsound("click1.mp3")
# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
        self.create_splashframe
        playsound("click1.mp3")
# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
        playsound("click1.mp3")
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.destroy()
        self.quit()
        playsound("click1.mp3")

    # this sets the gun terminal identification
    # this can also be expanded to do other things if you want to alter the script
    def on_keypress_a(self, evet):
        which_gun = self.gun.get()
        which_gun = "A"
        self.gun.set(which_gun)

        playsound("click1.mp3")

    def on_keypress_b(self, evet):
        which_gun = self.gun.get()
        which_gun = "B"
        self.gun.set(which_gun)

        playsound("click1.mp3")

    def on_keypress_c(self, evet):
        which_gun = self.gun.get()
        which_gun = "C"
        self.gun.set(which_gun)

        playsound("click1.mp3")

    def on_keypress_d(self, evet):
        which_gun = self.gun.get()
        which_gun = "D"
        self.gun.set(which_gun)

        playsound("click1.mp3")


#
#
# End fire menu class and related functions
#
#
#Begin secret credits(kudos) screen
#
#

class KudosFrame(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.geometry('640x400')
        self.title("Secret credits screen")
        tk.Grid.rowconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 0, weight=1, uniform='a')
        tk.Grid.rowconfigure(self, 1, weight=1, uniform='a')
        tk.Grid.columnconfigure(self, 1, weight=1, uniform='a')

        r0c0 = tk.Button(self, text='Close', command=self.destroy, bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r0c0.grid(row=0, column=0, sticky="NSEW")
        r1c0 = tk.Label(self, text ='Alienslegacy.com Credits \n knoxvilles_joker aka gabriel vos new script  \n martinr1000 font and some coding help \n MLR 2007 for original flash script \n Facebook.com  theuscm \n youtube.com/channel/UC4KYYScA5WcdCZeiU6lcjdA \n cobra_shipwreck channel aka knoxvilles_joker', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r1c0.grid(row=1, column=0, sticky="NSEW")
        r1c1 = tk.Label(self, text =' ', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r1c1.grid(row=1, column=1, sticky="NSEW")
        r0c1 = tk.Label(self, text ='Python-forum.io credits \n Yoriz coding pointers and help \n ndc85430 coding critique \n ', bg='black', fg='yellow',highlightbackground='yellow', highlightcolor='black', activebackground='yellow')
        r0c1.grid(row=0, column=1, sticky="NSEW")

        # These are the bind key definitions

        self.bind("<KeyPress-r>", self.on_keypress_r)

        self.bind("<KeyPress-space>", self.on_keypress_space)
        self.bind("<KeyPress-k>", self.on_keypress_k)
        self.bind("<KeyPress-q>", self.on_keypress_q)

    def on_button(self):
        secondframe = SecondFrame(self)
        self.withdraw()
        self.wait_window(secondframe)
        self.deiconify()
    def kudos(self):
        kudosframe = KudosFrame(self)
        self.withdraw()
        self.wait_window(kudosframe)
        self.deiconify()
    # this appears to launch the initial window
    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()


# this reloads the game, you have to click it to make it the active window again
    def on_keypress_r(self, evet):
        self.destroy()
         
        self.create_splashframe # this appears to launch the initial window
       


    def create_splashframe(self):
        splashframe = SplashFrame(self)
        self.withdraw()
        self.wait_window(splashframe)
        self.deiconify()


    def on_keypress_k(self, evet):
        print("k pressed")
        self.kudos()
        playsound("click1.mp3")

# this launches you to window three, the fire select window
    def on_keypress_space(self, evet):
        print("space pressed")
        self.on_button()
        playsound("click1.mp3")
# this quits and closes the window by hitting a single key
    def on_keypress_q(self, evet):
        self.destroy()
        self.quit()
        playsound("click1.mp3")



#
# End secret credits(kudos) screen
#
#
#
# The below two commands run the entire script

tk_app = TkApp()
tk_app.mainloop()

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Apr 19, 2021 2:15 am 

Service Number: A05/TQ2.0.32141E1
Country: United States
adjusted to 22khz to play nice with software.

warning1.mp3 [2.06 KiB]
Downloaded 6 times


_________________
The impossible takes a while longer and goes over budget too...
Top
 Profile  
Reply with quote  
 Post subject: Re: idea on flash replacement for sentry gun terminal progra
PostPosted: Mon Apr 19, 2021 7:15 am 
Proceed on a 2-1-6...
User avatar

Location: Sunny Sussex
Service Number: A02/TQ2.0.52141E1
Country: United Kingdom
That sounds spot on!

_________________
A02/TQ2.0.52141E1

"Errr... Roger that's a 2-1-6..."


Top
 Profile  
Reply with quote  
 Post subject: Re: idea on flash replacement for sentry gun terminal progra
PostPosted: Mon Apr 19, 2021 1:09 pm 

Service Number: A05/TQ2.0.32141E1
Country: United States
ilovethecorps wrote:
That sounds spot on!



Please, try the script yourself.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: