Skip to content

Commit

Permalink
Add resource path and ui y-axis fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vs4vijay committed Nov 23, 2019
1 parent c1575f6 commit fb0d75d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions telegram/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from telethon.tl.functions.channels import JoinChannelRequest, LeaveChannelRequest, InviteToChannelRequest

from telegram.core.logger import logger
from telegram.core.util import resource_path

SESSION_FOLDER = '.'

Expand All @@ -21,6 +22,7 @@ async def initiate(self, loop=None):
# self.session = MemorySession(config['APP_SESSION'])
# self.session = MemorySession()
session_file = f'{SESSION_FOLDER}/{self.config["APP_SESSION"]}'
session_file=resource_path(session_file)
self.client = TelegramClient(session_file, self.config['API_KEY'], self.config['API_HASH'], loop=loop)
self.client.session.save_entities = False
session = StringSession.save(self.client.session)
Expand Down
9 changes: 9 additions & 0 deletions telegram/core/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
import sys

def resource_path(relative_path):
if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS
else:
base_path = os.path.abspath('.')
return os.path.join(base_path, relative_path)
2 changes: 0 additions & 2 deletions telegram/gui/telegram_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def get_ui_path(self, ui_file):
else:
bundle_dir = os.path.dirname(os.path.abspath(__file__))
ui_path = f'{bundle_dir}/ui/{ui_file}'
print('bundle_dir', bundle_dir)
print('ui_path', ui_path)
return ui_path

def init_components(self):
Expand Down
2 changes: 1 addition & 1 deletion telegram/gui/ui/form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<y>20</y>
<width>471</width>
<height>301</height>
</rect>
Expand Down

0 comments on commit fb0d75d

Please sign in to comment.