OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why is my python executable not running like my python file?

  • Thread starter Thread starter Rickey Gates
  • Start date Start date
R

Rickey Gates

Guest
All the other things in my code is running good when I convert it to an executable file using pyinstaller except for this window could you please assist me with some ideas as this is my first time creating a .exe file. When i open the executable and click on the button to open this window. This window opens up but there is nothing on the window. All dropdown lists and buttons are not showing.

line i used to create executable is:

pyinstaller --onefile -w - file_name.py

Code:
def open_diagnose_window():
     global diagnose_date_entry, diagnose_description_entry, diagnose_findings_entry, diagnose_action_entry, severity_drop_down
     global site_drop_down, plant_drop_down, area_drop_down, equipment_drop_down, component_drop_down
     # Create a new window for diagnosing machines
     diagnose_window = tk.Toplevel(root)
     diagnose_window.title("Diagnose Machines")
     diagnose_window.config(bg=window_bg)
     diagnose_window.state('zoomed')
     
     conn = pyo.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=' + db_file_path)  # Use the selected database file
     print(conn)
     cursor = conn.cursor()
     cursor.execute("select * from Site_Details")
     data = cursor.fetchall()

     # Function to update options for plant_drop_down
     def update_plant_options(*args):
          # Clear all dependent dropdowns
          plant_drop_down.set('')
          area_drop_down.set('')
          equipment_drop_down.set('')
          component_drop_down.set('')

          # Update plant_drop_down based on site_drop_down selection
          site_value = site_drop_down.get()
          if site_value:
               plant_values = list(set(row[2] for row in data if row[1] == site_value))
               plant_drop_down['values'] = sorted(plant_values)

     # Function to update options for area_drop_down
     def update_area_options(*args):
          # Clear all dependent dropdowns
          area_drop_down.set('')
          equipment_drop_down.set('')
          component_drop_down.set('')

          # Update area_drop_down based on both site and plant selections
          site_value = site_drop_down.get()
          plant_value = plant_drop_down.get()
          if site_value and plant_value:
               area_values = list(set(row[3] for row in data if row[1] == site_value and row[2] == plant_value))
               area_drop_down['values'] = sorted(area_values)

     # Function to update options for equipment_drop_down
     def update_equipment_options(*args):
          # Clear all dependent dropdowns
          equipment_drop_down.set('')
          component_drop_down.set('')

          # Update equipment_drop_down based on site, plant, and area selections
          site_value = site_drop_down.get()
          plant_value = plant_drop_down.get()
          area_value = area_drop_down.get()
          if site_value and plant_value and area_value:
               equipment_values = list(set(row[4] for row in data if row[1] == site_value and row[2] == plant_value and row[3] == area_value))
               equipment_drop_down['values'] = sorted(equipment_values)

          # Function to update options for component_drop_down
     
     def update_component_options(*args):
          # Clear all dependent dropdowns
          component_drop_down.set('')

          # Update component_drop_down based on site, plant, area, and equipment selections
          site_value = site_drop_down.get()
          plant_value = plant_drop_down.get()
          area_value = area_drop_down.get()
          equipment_value = equipment_drop_down.get()
          if site_value and plant_value and area_value and equipment_value:
               component_values = list(set(row[5] for row in data if row[1] == site_value and row[2] == plant_value and row[3] == area_value and row[4] == equipment_value))
               component_drop_down['values'] = sorted(component_values)
               # Clear all dependent dropdowns
               component_drop_down.set('')

                    # Update component_drop_down based on equipment_drop_down selection
               equipment_value = equipment_drop_down.get()
               if equipment_value:
                    component_values = list(set(row[5] for row in data if row[4] == equipment_value))
                    component_drop_down['values'] = sorted(component_values)

     # Fetch data from database
     #data = fetch_data()

     # Labels and Entry Boxes for site, plant, area, equipment ID, and component
     diagnose_date_label = tk.Label(diagnose_window, text="Date Captured:", bg=lblcolor, fg=lbltext)
     diagnose_date_label.pack(pady=5)
     diagnose_date_entry = tk.Entry(diagnose_window, width=35)
     diagnose_date_entry.pack(pady=5)
     diagnose_date_entry.insert(0, "dd/mm/yyyy")
     diagnose_date_entry.bind("<1>", pick_date_diagnose)

     diagnose_site_label = tk.Label(diagnose_window, text="Choose Site:", bg=lblcolor, fg=lbltext)
     diagnose_site_label.pack(pady=5)
     # Create first dropdown with unique values from first column
     site_drop_down = ttk.Combobox(diagnose_window, width=30, values=sorted(list(set(row[1] for row in data))))
     site_drop_down.pack()
     site_drop_down.bind('<<ComboboxSelected>>', update_plant_options)

     diagnose_plant_label = tk.Label(diagnose_window, text="Choose Plant:", bg=lblcolor, fg=lbltext)
     diagnose_plant_label.pack(pady=5)
     # Create second dropdown with empty values initially
     plant_drop_down = ttk.Combobox(diagnose_window, width=30)
     plant_drop_down.pack()
     plant_drop_down.bind('<<ComboboxSelected>>', update_area_options)

     diagnose_area_label = tk.Label(diagnose_window, text="Choose Area:", bg=lblcolor, fg=lbltext)
     diagnose_area_label.pack(pady=5)
     # Create third dropdown with empty values initially
     area_drop_down = ttk.Combobox(diagnose_window, width=30)
     area_drop_down.pack()
     area_drop_down.bind('<<ComboboxSelected>>', update_equipment_options)

     diagnose_equipment_id_label = tk.Label(diagnose_window, text="Choose Equipment ID:", bg=lblcolor, fg=lbltext)
     diagnose_equipment_id_label.pack(pady=5)
     # Create fourth dropdown with empty values initially
     equipment_drop_down = ttk.Combobox(diagnose_window, width=30)
     equipment_drop_down.pack()
     equipment_drop_down.bind('<<ComboboxSelected>>', update_component_options)

     diagnose_component_label = tk.Label(diagnose_window, text="Choose Component:", bg=lblcolor, fg=lbltext)
     diagnose_component_label.pack(pady=5)
     # Create fifth dropdown with empty values initially
     component_drop_down = ttk.Combobox(diagnose_window, width=30)
     component_drop_down.pack()

     diagnose_description_label = tk.Label(diagnose_window, text="Choose Description:", bg=lblcolor, fg=lbltext)
     diagnose_description_label.pack(pady=5)
     diagnose_description_entry = tk.Entry(diagnose_window, width=35)
     diagnose_description_entry.pack(pady=5)    

     diagnose_findings_label = tk.Label(diagnose_window, text="Enter Findings:", bg=lblcolor, fg=lbltext)
     diagnose_findings_label.pack(pady=5)
     diagnose_findings_entry = tk.Entry(diagnose_window, width=35)
     diagnose_findings_entry.pack(pady=5)

     diagnose_action_label = tk.Label(diagnose_window, text="Enter Recommendation:", bg=lblcolor, fg=lbltext)
     diagnose_action_label.pack(pady=5)
     diagnose_action_entry = tk.Entry(diagnose_window, width=35)
     diagnose_action_entry.pack(pady=5)

     diagnose_severity_label = tk.Label(diagnose_window, text="Enter Severity:", bg=lblcolor, fg=lbltext)
     diagnose_severity_label.pack(pady=5)
     severity_options = ["P0 - Normal", "P1 - Borderline", "P2 - Action", "P3 - Urgent", "P4 - Critical"]
     severity_drop_down = ttk.Combobox(diagnose_window, width=35, values=severity_options)
     severity_drop_down.pack()

     diagnose_submit_button = tk.Button(
          diagnose_window, 
          command=diagnose_to_database,
          text="Submit", 
          background=button_bg,
          foreground=button_fg,
          highlightthickness=2,
          width=20,
          border=0,
          cursor="hand2",
          font=('arial', 12, 'bold')
     )
     diagnose_submit_button.pack(pady=5)

     close_diagnose_window_button = tk.Button(
          diagnose_window, 
          text="Close", 
          command=diagnose_window.destroy, 
          background=button_bg,
          foreground=button_fg,
          highlightthickness=2,
          width=20,
          border=0,
          cursor="hand2",
          font=('arial', 12, 'bold')
     )
     close_diagnose_window_button.pack(pady=10)
     conn.close()
     # Add widgets and functionality for diagnosing machines
<p>All the other things in my code is running good when I convert it to an executable file using <code>pyinstaller</code> except for this window could you please assist me with some ideas as this is my first time creating a .exe file.
When i open the executable and click on the button to open this window. This window opens up but there is nothing on the window. All dropdown lists and buttons are not showing.</p>
<p>line i used to create executable is:</p>
<p><code>pyinstaller --onefile -w - file_name.py</code></p>
<pre><code>def open_diagnose_window():
global diagnose_date_entry, diagnose_description_entry, diagnose_findings_entry, diagnose_action_entry, severity_drop_down
global site_drop_down, plant_drop_down, area_drop_down, equipment_drop_down, component_drop_down
# Create a new window for diagnosing machines
diagnose_window = tk.Toplevel(root)
diagnose_window.title("Diagnose Machines")
diagnose_window.config(bg=window_bg)
diagnose_window.state('zoomed')

conn = pyo.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=' + db_file_path) # Use the selected database file
print(conn)
cursor = conn.cursor()
cursor.execute("select * from Site_Details")
data = cursor.fetchall()

# Function to update options for plant_drop_down
def update_plant_options(*args):
# Clear all dependent dropdowns
plant_drop_down.set('')
area_drop_down.set('')
equipment_drop_down.set('')
component_drop_down.set('')

# Update plant_drop_down based on site_drop_down selection
site_value = site_drop_down.get()
if site_value:
plant_values = list(set(row[2] for row in data if row[1] == site_value))
plant_drop_down['values'] = sorted(plant_values)

# Function to update options for area_drop_down
def update_area_options(*args):
# Clear all dependent dropdowns
area_drop_down.set('')
equipment_drop_down.set('')
component_drop_down.set('')

# Update area_drop_down based on both site and plant selections
site_value = site_drop_down.get()
plant_value = plant_drop_down.get()
if site_value and plant_value:
area_values = list(set(row[3] for row in data if row[1] == site_value and row[2] == plant_value))
area_drop_down['values'] = sorted(area_values)

# Function to update options for equipment_drop_down
def update_equipment_options(*args):
# Clear all dependent dropdowns
equipment_drop_down.set('')
component_drop_down.set('')

# Update equipment_drop_down based on site, plant, and area selections
site_value = site_drop_down.get()
plant_value = plant_drop_down.get()
area_value = area_drop_down.get()
if site_value and plant_value and area_value:
equipment_values = list(set(row[4] for row in data if row[1] == site_value and row[2] == plant_value and row[3] == area_value))
equipment_drop_down['values'] = sorted(equipment_values)

# Function to update options for component_drop_down

def update_component_options(*args):
# Clear all dependent dropdowns
component_drop_down.set('')

# Update component_drop_down based on site, plant, area, and equipment selections
site_value = site_drop_down.get()
plant_value = plant_drop_down.get()
area_value = area_drop_down.get()
equipment_value = equipment_drop_down.get()
if site_value and plant_value and area_value and equipment_value:
component_values = list(set(row[5] for row in data if row[1] == site_value and row[2] == plant_value and row[3] == area_value and row[4] == equipment_value))
component_drop_down['values'] = sorted(component_values)
# Clear all dependent dropdowns
component_drop_down.set('')

# Update component_drop_down based on equipment_drop_down selection
equipment_value = equipment_drop_down.get()
if equipment_value:
component_values = list(set(row[5] for row in data if row[4] == equipment_value))
component_drop_down['values'] = sorted(component_values)

# Fetch data from database
#data = fetch_data()

# Labels and Entry Boxes for site, plant, area, equipment ID, and component
diagnose_date_label = tk.Label(diagnose_window, text="Date Captured:", bg=lblcolor, fg=lbltext)
diagnose_date_label.pack(pady=5)
diagnose_date_entry = tk.Entry(diagnose_window, width=35)
diagnose_date_entry.pack(pady=5)
diagnose_date_entry.insert(0, "dd/mm/yyyy")
diagnose_date_entry.bind("<1>", pick_date_diagnose)

diagnose_site_label = tk.Label(diagnose_window, text="Choose Site:", bg=lblcolor, fg=lbltext)
diagnose_site_label.pack(pady=5)
# Create first dropdown with unique values from first column
site_drop_down = ttk.Combobox(diagnose_window, width=30, values=sorted(list(set(row[1] for row in data))))
site_drop_down.pack()
site_drop_down.bind('<<ComboboxSelected>>', update_plant_options)

diagnose_plant_label = tk.Label(diagnose_window, text="Choose Plant:", bg=lblcolor, fg=lbltext)
diagnose_plant_label.pack(pady=5)
# Create second dropdown with empty values initially
plant_drop_down = ttk.Combobox(diagnose_window, width=30)
plant_drop_down.pack()
plant_drop_down.bind('<<ComboboxSelected>>', update_area_options)

diagnose_area_label = tk.Label(diagnose_window, text="Choose Area:", bg=lblcolor, fg=lbltext)
diagnose_area_label.pack(pady=5)
# Create third dropdown with empty values initially
area_drop_down = ttk.Combobox(diagnose_window, width=30)
area_drop_down.pack()
area_drop_down.bind('<<ComboboxSelected>>', update_equipment_options)

diagnose_equipment_id_label = tk.Label(diagnose_window, text="Choose Equipment ID:", bg=lblcolor, fg=lbltext)
diagnose_equipment_id_label.pack(pady=5)
# Create fourth dropdown with empty values initially
equipment_drop_down = ttk.Combobox(diagnose_window, width=30)
equipment_drop_down.pack()
equipment_drop_down.bind('<<ComboboxSelected>>', update_component_options)

diagnose_component_label = tk.Label(diagnose_window, text="Choose Component:", bg=lblcolor, fg=lbltext)
diagnose_component_label.pack(pady=5)
# Create fifth dropdown with empty values initially
component_drop_down = ttk.Combobox(diagnose_window, width=30)
component_drop_down.pack()

diagnose_description_label = tk.Label(diagnose_window, text="Choose Description:", bg=lblcolor, fg=lbltext)
diagnose_description_label.pack(pady=5)
diagnose_description_entry = tk.Entry(diagnose_window, width=35)
diagnose_description_entry.pack(pady=5)

diagnose_findings_label = tk.Label(diagnose_window, text="Enter Findings:", bg=lblcolor, fg=lbltext)
diagnose_findings_label.pack(pady=5)
diagnose_findings_entry = tk.Entry(diagnose_window, width=35)
diagnose_findings_entry.pack(pady=5)

diagnose_action_label = tk.Label(diagnose_window, text="Enter Recommendation:", bg=lblcolor, fg=lbltext)
diagnose_action_label.pack(pady=5)
diagnose_action_entry = tk.Entry(diagnose_window, width=35)
diagnose_action_entry.pack(pady=5)

diagnose_severity_label = tk.Label(diagnose_window, text="Enter Severity:", bg=lblcolor, fg=lbltext)
diagnose_severity_label.pack(pady=5)
severity_options = ["P0 - Normal", "P1 - Borderline", "P2 - Action", "P3 - Urgent", "P4 - Critical"]
severity_drop_down = ttk.Combobox(diagnose_window, width=35, values=severity_options)
severity_drop_down.pack()

diagnose_submit_button = tk.Button(
diagnose_window,
command=diagnose_to_database,
text="Submit",
background=button_bg,
foreground=button_fg,
highlightthickness=2,
width=20,
border=0,
cursor="hand2",
font=('arial', 12, 'bold')
)
diagnose_submit_button.pack(pady=5)

close_diagnose_window_button = tk.Button(
diagnose_window,
text="Close",
command=diagnose_window.destroy,
background=button_bg,
foreground=button_fg,
highlightthickness=2,
width=20,
border=0,
cursor="hand2",
font=('arial', 12, 'bold')
)
close_diagnose_window_button.pack(pady=10)
conn.close()
# Add widgets and functionality for diagnosing machines
</code></pre>
 

Latest posts

Top