MCPcopy Index your code
hub / github.com/AmberSahdev/Open-Interface / __init__

Method __init__

app/ui.py:243–286  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

241
242 class MainWindow(ttk.Window):
243 def __init__(self):
244 settings = Settings()
245 settings_dict = settings.get_dict()
246 theme = settings_dict.get('theme', 'superhero')
247
248 try:
249 super().__init__(themename=theme)
250 except:
251 super().__init__() # https://github.com/AmberSahdev/Open-Interface/issues/35
252
253 self.title('Open Interface')
254 window_width = 450
255 window_height = 270
256 self.minsize(window_width, window_height)
257
258 # Set the geometry of the window
259 # Calculate position for bottom right corner
260 screen_width = self.winfo_screenwidth()
261 x_position = screen_width - window_width - 10 # 10px margin from the right edge
262 y_position = 50 # 50px margin from the bottom edge
263 self.geometry(f'{window_width}x{window_height}+{x_position}+{y_position}')
264
265 # PhotoImage object needs to persist as long as the app does, hence it's a class object.
266 path_to_icon_png = Path(__file__).resolve().parent.joinpath('resources', 'icon.png')
267 # path_to_microphone_png = Path(__file__).resolve().parent.joinpath('resources', 'microphone.png')
268 self.logo_img = ImageTk.PhotoImage(Image.open(path_to_icon_png).resize((50, 50)))
269 # self.mic_icon = ImageTk.PhotoImage(Image.open(path_to_microphone_png).resize((18, 18)))
270
271 # This adds app icon in linux which pyinstaller can't
272 self.tk.call('wm', 'iconphoto', self._w, self.logo_img)
273
274 ###
275 # MP Queue to facilitate communication between UI and Core.
276 # Put user requests received from UI text box into this queue which will then be dequeued in App to be sent
277 # to core.
278 self.user_request_queue = Queue()
279
280 # Put messages to display on the UI here so we can dequeue them in the main thread
281 self.message_display_queue = Queue()
282 # Set up periodic UI processing
283 self.after(200, self.process_message_display_queue)
284 ###
285
286 self.create_widgets()
287
288 def change_theme(self, theme_name: str) -> None:
289 self.style.theme_use(theme_name)

Callers

nothing calls this directly

Calls 4

get_dictMethod · 0.95
create_widgetsMethod · 0.95
SettingsClass · 0.90
__init__Method · 0.45

Tested by

no test coverage detected