AttributeError: the 'module' object does not have the 'Hardware' attribute

Hi guys, I am creating a UBT GUI program. I have a problem that I want to use several programs and then transfer them to others:

from tkinter import *
import os
import variables as v
import functions as f
#Functions :

     #Configuration of the window
root=Tk()
root.configure(bg=v.bg_color)
root.geometry(v.resolution)
root.title(v.title)
     #G.U.I.
         #Message :
message = Label(root, text="Choose your category:", anchor=W,bg=v.bg_color)
message.pack(fill=X)
    #Category Buttons :

frame=Frame(root)
hard_button=Button(frame, text="Hardware",bg=v.bg_color,command=f.Hardware)
hard_button.config()
hard_button.pack(side=LEFT)
root.mainloop()

this is the part that you see in the line:    hard_button=Button(frame, text="Hardware",bg=v.bg_color,command=f.Hardware) in the command I have the f.Hardware command, this is my problem. f.Hardware is another program that I import inside python so that everything is beautiful and neat. But I have a problem, this is what:

import os
import variables as v
import tkinter as tk
import gui as g

def new_hard_window():
     g.root.destroy()

def Hardware():
    new_hard_window()
    hard_path=os.chdir(v.path+"Hardware")
    print(os.listdir(hard_path))

I know that one error is in the first function, and the second will be the first line in the second, but I do not know how to fix it. If you want to run the code on your system, then I also provide my other file with variables. Thanks guys a lot !!!

 path="N:\Python_Programming\Hangman\\"
 bg_color="#FFFFFF"
 resolution="200x90"
 title="Hangman"

Feel free to change the path: -P

0
1

, python , python -. , :

a.py

import b
print('Import %s' % __name__)

b.py

import a
print('Import %s' % __name__)

, python a.py, :

Import a
Import b
Import __main__

? python __main__ . , , b, a. a.py , python a. , , __main__, - a.

, __main__ b, a. a.py. b b, , , a, - Import a. , b Import b. , __main__, a.py ( __main__!), Import __main__.

, : gui (, , python gui.py), functions functions, gui. , a.py b.py , gui __main__, , functions gui, gui gui gui.

, : __main__, 4 import functions as f, functions, 4 import gui as g. gui.py, gui, 4, functions, functions.py. , 4 functions, functions, .. new_hard_window Hardware. , 19:

hard_button=Button(frame, text="Hardware",bg=v.bg_color,command=f.Hardware)

Hardware functions aka f, . .

, python script . , script script, .

0

All Articles