'Region' is not defined when attempting to import

Asked by Ethan Perry on 2020-09-25

I'm attempting to define all of my regions/images as variables inside of a separate file (definedregions.sikuli) to make it easier to work. I first tried importing from my files as a .py file, and it said region not defined.
I've tried importing it using the 4 lines below taken from the docs.
import os
myPath = os.path.dirname(getBundlePath())
if not myPath in sys.path: sys.path.append(myPath)
import definedregions

This still gives the region not defined error, I've tried moving my definedregions.sikuli(file I'm attempting to import) to the same folder as the main script, inside the main script's .sikuli folder, moving definedregions.py into the main scripts .sikuli folder and nothing fixes the same error that shows every time.

I have the feeling I'm overlooking something basic but I'm not sure :P
I've tried different scripts from similar questions but nothing seems to work :(

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Ethan Perry
Solved:
2020-09-25
Last query:
2020-09-25
Last reply:
Ethan Perry (1m4) said : #1

error message:
[error] script [ Testing ] stopped with error in line 5
[error] NameError ( !!WHILE IMPORTING!! name 'Region' is not defined )
[error] --- Traceback --- error source first
line: module ( function ) statement
1: definedregions ( <module> ) REGtaskbar = Region(0,1040,1920,40)
5: main ( <module> ) import definedregions
[error] --- Traceback --- end --------------

Ethan Perry (1m4) said : #2

After putting "from sikuli.Sikuli import *" at the beginning of my definedregions script, it doesn't have any issues importing but later when it gets to using a region (called REGtaskbar) it says:

[error] script [ Testing ] stopped with error in line 10
[error] NameError ( name 'REGtaskbar' is not defined )
[error] --- Traceback --- error source first
line: module ( function ) statement
10: main ( <module> ) REGtaskbar.find(taskbaricon)
[error] --- Traceback --- end --------------

Ethan Perry (1m4) said : #4

It appears the extra definedregions.sikuli I had inside the main sikuli folder was messing it up, seems fine now