half got avatar

master
marxzuckerburg 4 years ago
parent 713f28d7d9
commit e795f01f6c

@ -149,7 +149,7 @@ class MapWidget(MDDialog2):
odir=PATH_MAPS
if not os.path.exists(odir): os.makedirs(odir)
ofn=os.path.join(odir,f't_{len(self.points)}.png')
plt.gca().invert_yaxis()
# plt.gca().invert_yaxis()
plt.savefig(ofn, format='png',transparent=True,pad_inches=0.1,bbox_inches = 'tight')
# flip?

@ -21,7 +21,7 @@ from copy import copy,deepcopy
from kivy.animation import Animation
from main import MyLabel,COLOR_ICON
from misc import *
import shutil
class ProfileAvatar(Image):
@ -60,8 +60,15 @@ class ProfileAvatar(Image):
self.handle_selection(path)
def handle_selection(self, selection):
self.selection = selection
raise Exception(selection)
if selection and type(selection)==list:
fnfn = selection[0]
_,ext=os.path.splitext(fnfn)
if ext[1:] in ALLOWED_IMG_EXT:
#avatar_fnfn = os.path.join(PATH_AVATAR,self.com)
self.parent.parent.parent.parent.parent.change_avatar(fnfn)
class LayoutAvatar(MDBoxLayout): pass
@ -113,7 +120,7 @@ def circularize_img(img_fn, width, im=None, do_crop=True,bw=False,resize=True,ci
log=App.get_running_app().log
#if not im:
im = Image.open(img_fn)
im = Image.open(img_fn).convert('RGB')
log('??',im)
@ -222,7 +229,9 @@ class ProfileScreen(ProtectedScreen):
def make_profile_img(self,width,do_crop=True,circ_img=None,bw=False,circularize=True):
img_src = os.path.join(PATH_GUI_ASSETS, 'avatars', f'{self.app.username}.png')
img_src = os.path.join(PATH_AVATARS, f'{self.app.comrad.name}.png')
if not os.path.exists(img_src):
img_src = os.path.join(PATH_GUI_ASSETS, 'avatars', f'{self.app.username}.png')
if not os.path.exists(img_src):
img_src=PATH_DEFAULT_AVATAR
@ -237,9 +246,26 @@ class ProfileScreen(ProtectedScreen):
avatar_layout.height=dp(width)
avatar_layout.width=dp(width)
avatar_layout.add_widget(avatar)
return (circ_img,byte,avatar,avatar_layout)
return (circ_img,byte,avatar,avatar_layout)
def change_avatar(self,fnfn,width=AVATAR_WIDTH):
# raise Exception(f'Got filename! {fnfn}')
if not os.path.exists(fnfn): return
ext=os.path.splitext(fnfn)[1]
ofnfn=os.path.join(PATH_AVATARS,self.app.comrad.name+ext)
shutil.copyfile(fnfn,ofnfn)
# re-get circular image
# self.avatar_layout.remove_widget(self.avatar)
# self.on_pre_enter()
self.page_layout.remove_widget(self.avatar_layout)
self.avatar_img, self.avatar_img_bytes, self.avatar, self.avatar_layout = \
self.make_profile_img(width)
self.avatar.screen = self
self.page_layout.add_widget(self.avatar_layout,1)
# self.avatar_layout.add_widget(self.avatar)
def on_pre_enter(self, width=300):
def on_pre_enter(self, width=AVATAR_WIDTH):
if not super().on_pre_enter(): return
if not self.clock_scheduled:

@ -32,15 +32,18 @@ PATH_SUPER_SECRET_OP_KEY = os.path.join(PATH_SUPER_SECRETS,'.comrad.op.key')
PATH_MAPS = os.path.join(PATH_COMRAD,'maps')
PATH_LOG_OUTPUT = os.path.join(PATH_COMRAD,'logs')
PATH_AVATARS = os.path.join(PATH_COMRAD,'avatars')
for x in [PATH_COMRAD,PATH_COMRAD_DATA,PATH_COMRAD_KEYS,PATH_QRCODES,PATH_SECRETS,PATH_SUPER_SECRETS,PATH_LOG_OUTPUT]:
for x in [PATH_COMRAD,PATH_COMRAD_DATA,PATH_COMRAD_KEYS,PATH_QRCODES,PATH_SECRETS,PATH_SUPER_SECRETS,PATH_LOG_OUTPUT,PATH_AVATARS]:
if not os.path.exists(x):
os.makedirs(x)
CRYPT_USE_SECRET = True
PATH_CRYPT_SECRET = os.path.join(PATH_SECRETS,'.salt')
PATH_CRYPT_SECRET_KEY = os.path.join(PATH_SECRETS,'.key')
AVATAR_WIDTH=300
# etc
BSEP=b'||||||||||'
@ -60,7 +63,6 @@ PATH_GUI = os.path.join(PATH_REPO,'comrad','app')
PATH_GUI_ASSETS = os.path.join(PATH_GUI,'assets')
PATH_DEFAULT_AVATAR = os.path.join(PATH_GUI_ASSETS,'avatars','britney2.jpg')
PATH_REPO = PATH_APP = os.path.abspath(os.path.dirname(__file__))
# PATH_APP = os.path.join(PATH_REPO,'comrad')
# PATH_BUILTIN_KEYCHAINS_ENCR = os.path.join(PATH_APP,'.builtin.keychains.encr')
@ -83,7 +85,7 @@ KEYNAMES = [
OPERATOR_INTERCEPT_MESSAGE = "If you'd like to make a call, please hang up and try again. If you need help, hang up, and then dial your operator."
ALLOWED_IMG_EXT = {'png','jpg','jpeg','gif'}
# KEYMAKER_DEFAULT_KEYS_TO_SAVE = ['pubkey_encr', 'privkey_encr', 'adminkey_encr']
# KEYMAKER_DEFAULT_KEYS_TO_RETURN = ['pubkey_decr_encr', 'privkey_decr_encr', 'adminkey_decr_encr']

Loading…
Cancel
Save