-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
95 lines (77 loc) · 2.83 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from alert import *
from cards import Cards
from config import BaseConfig, LocalConfig
from dearpygui.logger import mvLogger
from openlistings import OpenListings
from os import mkdir
from os.path import abspath, isdir, expandvars
from sets import Sets
from wallet import Wallet
from appwindow import AppWindow
import dearpygui.dearpygui as dpg
import dumper
# Init logging
dumper.max_depth = 10
logger = mvLogger()
AppVersion = "1.0 alpha"
AppName = "Archivist's Pride"
# Load configuration data
baseConfig = BaseConfig(logInfoCallback=logger.log, logErrorCallback=logger.log_error)
localConfig = LocalConfig(logInfoCallback=logger.log, logErrorCallback=logger.log_error)
cards = Cards(logInfoCallback=logger.log, logErrorCallback=logger.log_error)
AppDataRoot = expandvars(localConfig.Get('AppDataRoot', abspath(".\_Data")))
CacheRoot = localConfig.Set('CacheRoot', f"{AppDataRoot}\Cache")
ImageCacheRoot = localConfig.Set('ImageCacheRoot', f"{localConfig.Get('CacheRoot')}\Images")
# Ensure the roots exist
if not isdir(AppDataRoot):
mkdir(AppDataRoot)
if not isdir(CacheRoot):
mkdir(CacheRoot)
if not isdir(ImageCacheRoot):
mkdir(ImageCacheRoot)
# Init UI
MainWindow = AppWindow(
width=1280,
height=1024,
baseConfig=baseConfig,
label=AppName)
dpg.set_primary_window(MainWindow.window, True)
OpenListingsWindow = OpenListings(
width=600,
height=300,
baseConfig=baseConfig,
localConfig=localConfig,
logInfoCallback=logger.log,
logErrorCallback=logger.log_error)
WalletWindow = Wallet(
width=1280,
height=1024,
mainWindow = MainWindow,
baseConfig=baseConfig,
localConfig=localConfig,
logInfoCallback=logger.log,
logErrorCallback=logger.log_error)
SetsWindow = Sets(
width=800,
height=400,
cards=cards,
walletAddress=localConfig.Get('WalletAddress'),
contractAddress=baseConfig.Get('ContractAddress'),
logInfoCallback=logger.log,
logErrorCallback=logger.log_error)
dpg.add_menu_item(parent=MainWindow.ViewMenu, label="Listings", callback=lambda: OpenListingsWindow.Show())
dpg.add_menu_item(parent=MainWindow.ViewMenu, label="Sets", callback=lambda: SetsWindow.Show())
dpg.add_menu_item(parent=MainWindow.ViewMenu, label="Wallet", callback=lambda: WalletWindow.Show())
dpg.add_menu_item(parent=MainWindow.ViewMenu, label="Log", callback=lambda: dpg.configure_item(logger.window_id, show=True))
# hide the logger by default
dpg.configure_item(logger.window_id, show=False)
dpg.setup_registries()
# https://github.com/hoffstadt/DearPyGui/wiki/Viewport#manual-viewport
vp = dpg.create_viewport(title=f"Archivist\'s Pride {AppVersion} by JERisBRISK")
# must be called before showing viewport
dpg.set_viewport_small_icon('parallel.ico')
dpg.set_viewport_large_icon('parallel.ico')
dpg.setup_dearpygui(viewport=vp)
dpg.show_viewport(vp)
dpg.maximize_viewport()
dpg.start_dearpygui()