2014-10-27 16:29:04 -06:00
# -*- coding: utf-8 -*-
2018-11-22 13:35:19 -06:00
from __future__ import absolute_import
2019-06-06 11:52:23 -05:00
from __future__ import unicode_literals
2014-10-27 16:29:04 -06:00
import wx
2018-11-22 13:35:19 -06:00
from . import baseDialog
2014-10-27 16:29:04 -06:00
2015-03-06 21:37:08 -06:00
class updateProfileDialog ( baseDialog . BaseWXDialog ) :
2021-06-16 16:18:41 -05:00
def __init__ ( self ) :
super ( updateProfileDialog , self ) . __init__ ( parent = None , id = - 1 )
self . SetTitle ( _ ( u " Update your profile " ) )
panel = wx . Panel ( self )
labelName = wx . StaticText ( panel , - 1 , _ ( u " &Name (50 characters maximum) " ) )
self . name = wx . TextCtrl ( panel , - 1 )
self . name . SetFocus ( )
dc = wx . WindowDC ( self . name )
dc . SetFont ( self . name . GetFont ( ) )
self . name . SetSize ( dc . GetTextExtent ( " 0 " * 50 ) )
labelLocation = wx . StaticText ( panel , - 1 , _ ( u " &Location " ) )
self . location = wx . TextCtrl ( panel , - 1 )
dc = wx . WindowDC ( self . location )
dc . SetFont ( self . location . GetFont ( ) )
self . location . SetSize ( dc . GetTextExtent ( " 0 " * 35 ) )
labelUrl = wx . StaticText ( panel , - 1 , _ ( u " &Website " ) )
self . url = wx . TextCtrl ( panel , - 1 )
dc = wx . WindowDC ( self . url )
dc . SetFont ( self . url . GetFont ( ) )
self . url . SetSize ( dc . GetTextExtent ( " 0 " * 22 ) )
labelDescription = wx . StaticText ( panel , - 1 , _ ( u " &Bio (160 characters maximum) " ) )
self . description = wx . TextCtrl ( panel , - 1 , size = ( 400 , 400 ) )
dc = wx . WindowDC ( self . description )
dc . SetFont ( self . description . GetFont ( ) )
self . description . SetSize ( dc . GetTextExtent ( " 0 " * 160 ) )
self . image = None
self . upload_image = wx . Button ( panel , - 1 , _ ( u " Upload a &picture " ) )
self . ok = wx . Button ( panel , wx . ID_OK , _ ( u " &Update profile " ) )
self . ok . SetDefault ( )
close = wx . Button ( panel , wx . ID_CANCEL , _ ( " &Close " ) )
sizer = wx . BoxSizer ( wx . VERTICAL )
nameBox = wx . BoxSizer ( wx . HORIZONTAL )
nameBox . Add ( labelName , 0 , wx . ALL , 5 )
nameBox . Add ( self . name , 0 , wx . ALL , 5 )
sizer . Add ( nameBox , 0 , wx . ALL , 5 )
locationBox = wx . BoxSizer ( wx . HORIZONTAL )
locationBox . Add ( labelLocation , 0 , wx . ALL , 5 )
locationBox . Add ( self . location , 0 , wx . ALL , 5 )
sizer . Add ( locationBox , 0 , wx . ALL , 5 )
urlBox = wx . BoxSizer ( wx . HORIZONTAL )
urlBox . Add ( labelUrl , 0 , wx . ALL , 5 )
urlBox . Add ( self . url , 0 , wx . ALL , 5 )
sizer . Add ( urlBox , 0 , wx . ALL , 5 )
descriptionBox = wx . BoxSizer ( wx . HORIZONTAL )
descriptionBox . Add ( labelDescription , 0 , wx . ALL , 5 )
descriptionBox . Add ( self . description , 0 , wx . ALL , 5 )
sizer . Add ( descriptionBox , 0 , wx . ALL , 5 )
sizer . Add ( self . upload_image , 5 , wx . CENTER , 5 )
btnBox = wx . BoxSizer ( wx . HORIZONTAL )
btnBox . Add ( self . ok , 0 , wx . ALL , 5 )
btnBox . Add ( close , 0 , wx . ALL , 5 )
sizer . Add ( btnBox , 0 , wx . ALL , 5 )
panel . SetSizer ( sizer )
self . SetClientSize ( sizer . CalcMin ( ) )
2014-10-27 16:29:04 -06:00
2021-06-16 16:18:41 -05:00
def set_name ( self , name ) :
self . set ( " name " , name )
2015-03-06 21:37:08 -06:00
2021-06-16 16:18:41 -05:00
def set_description ( self , description ) :
self . set ( " description " , description )
2015-03-06 21:37:08 -06:00
2021-06-16 16:18:41 -05:00
def set_location ( self , location ) :
self . set ( " location " , location )
2015-03-06 21:37:08 -06:00
2021-06-16 16:18:41 -05:00
def set_url ( self , url ) :
self . set ( " url " , url )
2015-03-06 21:37:08 -06:00
2021-06-16 16:18:41 -05:00
def change_upload_button ( self , uploaded = False ) :
if uploaded == False :
self . upload_image . SetLabel ( _ ( u " Upload a picture " ) )
else :
self . upload_image . SetLabel ( _ ( u " Discard image " ) )
2014-10-27 16:29:04 -06:00
2021-06-16 16:18:41 -05:00
def upload_picture ( self ) :
openFileDialog = wx . FileDialog ( self , _ ( u " Select the picture to be uploaded " ) , " " , " " , _ ( " Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif " ) , wx . FD_OPEN | wx . FD_FILE_MUST_EXIST )
if openFileDialog . ShowModal ( ) == wx . ID_CANCEL :
return None
return openFileDialog . GetPath ( )
2015-03-06 21:37:08 -06:00
2021-06-16 16:18:41 -05:00
def hide_upload_button ( self , hide ) :
self . upload_image . Enable ( hide )
2015-03-06 21:37:08 -06:00
2021-06-16 16:18:41 -05:00
def set_readonly ( self ) :
self . name . style = wx . TE_READONLY
self . name . Refresh ( )
self . description . style = wx . TE_READONLY
self . description . Refresh ( )
self . location . style = wx . TE_READONLY
self . location . Refresh ( )
self . url . style = wx . TE_READONLY
self . url . Refresh ( )
self . hide_upload_button ( False )
self . ok . Enable ( False )