-1

Im trying to create an application that runs in CMD where one of the files in the other directory sets the size of the window to fullscreen. However the method I tried won't open or load it. I debugged my profile and all the modules are already installed. It's just the function that won't load.

How the file directory is setup:

Application_map
|-Application.py
|-U7sI5C
  |-Module.py

Code in application.py:


try:
    import time
    from U7sI5C import (module, example, example)
except Ecxception as e:
    print("Some modules are missing! Install them and try again! {}".format(e))
    
Resize() #<---This is the module in module.py in the U7sI5C directory.
time.sleep(50)

Code in Modules.py:


try:
    import ctypes
    from os import system
    import sys
    import time
except Exception as e:
    print("Some modules are mssing! Install them and try again! {}".format(e))

def Resize():
    system("title " + "Lost Lifes")

    kernel32 = ctypes.WinDLL('kernel32')
    user32 = ctypes.WinDLL('user32')

    SW_MAXIMIZE = 3


    hWnd = kernel32.GetConsoleWindow()
    user32.ShowWindow(hWnd, SW_MAXIMIZE)
    time.sleep(50)

MdeGraaff
  • 122
  • 1
  • 11
  • is `module.py` or `Module.py` (uppercase M) you have used both in your question. Also, why do you import `example` twice? Where is `example` coming from? Where is `Resize` defined? Please provide more info and a proper overview of `module.py` – alec_djinn Oct 13 '20 at 12:35
  • `example` is just a placeholder and they are both lowercase. Sorry for the typo. Resize is defined in modules.py. I showed the code in my question. – MdeGraaff Oct 13 '20 at 12:36
  • Then you should call it as `module.Resize()` as you do with `time.sleep()` or import it via `from U7sI5C.module import Resize` – alec_djinn Oct 13 '20 at 12:38
  • That works! thanks. I'll be closing the question now. – MdeGraaff Oct 13 '20 at 12:40

2 Answers2

0

You can't call the function directly if you have imported module only. Or you import the function from U7sI5C.module import Resize or you call the function as part of the module module.Resize().

alec_djinn
  • 10,104
  • 8
  • 46
  • 71
0

I don't think you are able to include a python file from another directory by default. I found this question: Importing files from different folder. This says you may be able to fix it by adding to the Python Path. If you add it to the path you should be able to call it properly.

Boxman07
  • 13
  • 1
  • 4