Remove trailing whitespaces.

This commit is contained in:
Emmanuel Gil Peyrot 2013-01-18 17:55:34 +01:00
commit 27b3592e16
11 changed files with 899 additions and 899 deletions

View file

@ -49,7 +49,7 @@ class WxCard(TarotCard):
def draw(self, dc, x, y):
"""Draw the card on the device context
@param dc: device context
@param x: abscissa
@param x: abscissa
@param y: ordinate"""
dc.DrawBitmap(self.bitmap, x, y, True)
@ -152,7 +152,7 @@ class CardPanel(QuickCardGame,wx.Panel):
def onPaint(self, event):
dc = wx.PaintDC(self)
#We print the names to know who play where TODO: print avatars when available
max_x, max_y = self.GetSize()
border = 10 #border between nick and end of panel
@ -214,7 +214,7 @@ class CardPanel(QuickCardGame,wx.Panel):
def onMouseClick(self, event):
print "mouse click:",event.GetPosition()
pos_x,pos_y = event.GetPosition()
if self.state == "chien":
self.to_show = []
self.state = "wait"

View file

@ -41,11 +41,11 @@ class Chat(wx.Frame, QuickChat):
def __init__(self, target, host, type='one2one'):
wx.Frame.__init__(self, None, title=target, pos=(0,0), size=(400,200))
QuickChat.__init__(self, target, host, type)
QuickChat.__init__(self, target, host, type)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self.sizer)
self.splitter = wx.SplitterWindow(self, -1)
self.sizer.Add(self.splitter, 1, flag = wx.EXPAND)
@ -60,7 +60,7 @@ class Chat(wx.Frame, QuickChat):
self.conv_panel.SetSizer(self.conv_panel.sizer)
self.splitter.Initialize(self.conv_panel)
self.SetMenuBar(wx.MenuBar())
#events
self.Bind(wx.EVT_CLOSE, self.onClose, self)
self.Bind(wx.EVT_TEXT_ENTER, self.onEnterPressed, self.textBox)
@ -69,14 +69,14 @@ class Chat(wx.Frame, QuickChat):
self.font={}
self.font["points"] = self.chatWindow.GetFont().GetPointSize()
self.font["family"] = self.chatWindow.GetFont().GetFamily()
#misc
self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time
self.setType(self.type)
self.textBox.SetFocus()
self.Hide() #We hide because of the show toggle
def __createPresents(self):
"""Create a list of present people in a group chat"""
self.present_panel = wx.Panel(self.splitter)
@ -108,7 +108,7 @@ class Chat(wx.Frame, QuickChat):
self.__eraseMenus()
self.__createMenus_O2O()
self.historyPrint(profile=self.host.profile)
def startGame(self, game_type, referee, players):
"""Configure the chat window to start a game"""
if game_type=="Tarot":
@ -130,9 +130,9 @@ class Chat(wx.Frame, QuickChat):
"""Return class managing the game type"""
#TODO: check that the game is launched, and manage errors
if game_type=="Tarot":
return self.tarot_panel
return self.tarot_panel
elif game_type=="Quiz":
return self.quiz_panel
return self.quiz_panel
def setPresents(self, nicks):
"""Set the users presents in the contact list for a group chat
@ -141,7 +141,7 @@ class Chat(wx.Frame, QuickChat):
QuickChat.setPresents(self, nicks)
for nick in nicks:
self.present_panel.presents.replace(nick)
def replaceUser(self, nick, show_info=True):
"""Add user if it is not in the group list"""
debug (_("Replacing user %s") % nick)
@ -166,7 +166,7 @@ class Chat(wx.Frame, QuickChat):
menuBar = self.GetMenuBar()
for i in range(menuBar.GetMenuCount()):
menuBar.Remove(i)
def __createMenus_O2O(self):
"""create menu bar for one 2 one chat"""
info("Creating menus")
@ -190,7 +190,7 @@ class Chat(wx.Frame, QuickChat):
#events
wx.EVT_MENU(self, idTAROT, self.onStartTarot)
def __del__(self):
wx.Frame.__del__(self)
@ -202,7 +202,7 @@ class Chat(wx.Frame, QuickChat):
def onEnterPressed(self, event):
"""Behaviour when enter pressed in send line."""
self.host.sendMessage(self.target.short if self.type=='group' else self.target,
event.GetString(),
event.GetString(),
mess_type = "groupchat" if self.type=='group' else "chat",
profile_key=self.host.profile)
self.textBox.Clear()
@ -236,7 +236,7 @@ class Chat(wx.Frame, QuickChat):
self.chatWindow.AppendText("%s\n" % msg)
if not mymess:
self.__blink()
def printInfo(self, msg, type='normal'):
"""Print general info
@param msg: message to print
@ -265,7 +265,7 @@ class Chat(wx.Frame, QuickChat):
else:
full_jid = self.target
id = self.host.bridge.sendFile(full_jid, filename, {}, self.host.profile)
self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), self.host.profile)
self.host.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), self.host.profile)
def onStartTarot(self, e):
debug (_("Starting Tarot game"))

View file

@ -52,7 +52,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
self.empty_avatar = join(host.media_dir, 'misc/empty_avatar')
self.Bind(wx.EVT_LISTBOX, self.onSelected)
self.Bind(wx.EVT_LISTBOX_DCLICK, self.onActivated)
def __contains__(self, jid):
return bool(self.__find_idx(jid))
@ -107,7 +107,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
def __presentItemDefault(self, contact):
"""Make a basic presentation of string contacts in the list."""
return contact
def __presentItemJID(self, jid):
"""Make a nice presentation of the contact in the list for JID contacts."""
name = self.getCache(jid,'name')
@ -116,7 +116,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
if _show == None or _show == 'unavailable':
return None
show = filter(lambda x : x[0] == _show, const_STATUS)[0]
#show[0]==shortcut
#show[1]==human readable
#show[2]==color (or None)
@ -126,7 +126,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
#WxPython segfault, and it doesn't without nothing. I couldn't reproduce the case with a basic test script, so it need further investigation before reporting it
#to WxPython dev. Anyway, the program crash with a segfault, not a python exception, so there is definitely something wrong with WxPython.
#The case seems to happen when SimpleHtmlListBox parse the HTML with the <img> tag
html = """
<table border='0'>
<td>
@ -140,7 +140,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
""" % (avatar,
escape(nick or name or jid.node or jid.short),
show_html,
escape(status))
escape(status))
return html
@ -163,7 +163,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
gp_idx = self.Append(self.__presentGroup(group), Group(group))
else:
gp_idx = indexes[0]
_present = self.__presentItem(contact)
if _present:
self.Insert(_present, gp_idx+1, contact)
@ -199,7 +199,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
event.Skip(False)
else:
event.Skip()
def onActivated(self, event):
"""Called when a contact is clicked or activated with keyboard."""
data = self.getSelection()

View file

@ -36,7 +36,7 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
if server:
self.SetTitle(title+" (%s)" % server)
#Fonts
self.normal_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
self.bold_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD)
@ -61,10 +61,10 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
self.sizer.Add(self.panel, 1, flag=wx.EXPAND)
self.SetSizer(self.sizer)
self.SetAutoLayout(True)
#events
self.Bind(wx.EVT_CLOSE, self.onClose, self)
self.MakeModal()
self.panel.sizer.Add(wx.Window(self.panel, -1))
title_name = wx.StaticText(self.panel, -1, "Name")
@ -75,7 +75,7 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
self.panel.sizer.Add(title_type)
self.panel.sizer.Add(wx.Window(self.panel, -1))
self.panel.sizer.Add(wx.Window(self.panel, -1))
for gateway in gateways:
self.addGateway(gateway, gateways[gateway])
@ -94,20 +94,20 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
self.ext_server_panel.sizer.Add(ext_server_label)
self.ext_server_panel.sizer.Add(self.ext_server_text, 1, flag=wx.EXPAND)
self.ext_server_panel.sizer.Add(ext_server_button)
#self.panel.sizer.Fit(self)
self.sizer.Fit(self)
self.Show()
def browseExternalServer(self, event):
"""Open the gateway manager on given server"""
server = self.ext_server_text.GetValue()
debug(_("Opening gateways manager on [%s]") % server)
debug(_("Opening gateways manager on [%s]") % server)
id = self.host.bridge.findGateways(server, self.host.profile)
self.host.current_action_ids.add(id)
self.host.current_action_ids_cb[id] = self.host.onGatewaysFound
self.MakeModal(False)
self.MakeModal(False)
self.Destroy()
@ -121,7 +121,7 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
label=wx.StaticText(self.panel, -1, param['name'])
label.SetFont(self.normal_font)
#Then the transport type message
type_label_txt = self.getGatewayDesc(param['type'])
@ -134,7 +134,7 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
gateway_jid = event.GetEventObject().gateway_jid
id = self.host.bridge.in_band_register(gateway_jid, self.host.profile)
self.host.current_action_ids.add(id)
self.MakeModal(False)
self.MakeModal(False)
self.Destroy()
def unregister_cb(event):
@ -142,9 +142,9 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
gateway_jid = event.GetEventObject().gateway_jid
id = self.host.bridge.gatewayRegister("CANCEL",gateway_jid, None, self.host.profile)
self.host.current_action_ids.add(id)
self.MakeModal(False)
self.MakeModal(False)
self.Destroy()
reg_button = wx.Button(self.panel, -1, _("Register"), size=wx.Size(-1, 8))
reg_button.SetFont(self.button_font)
reg_button.gateway_jid = JID(gateway)
@ -153,7 +153,7 @@ class GatewaysManager(wx.Frame,QuickGatewaysManager):
unreg_button.SetFont(self.button_font)
unreg_button.gateway_jid = JID(gateway)
self.panel.Bind(wx.EVT_BUTTON, unregister_cb, unreg_button)
self.panel.sizer.Add(im_icon)
self.panel.sizer.Add(label)
self.panel.sizer.Add(type_label)

View file

@ -48,10 +48,10 @@ idFIND_GATEWAYS = range(10)
class ChatList(QuickChatList):
"""This class manage the list of chat windows"""
def createChat(self, target):
return Chat(target, self.host)
class MainWindow(wx.Frame, QuickApp):
"""main app window"""
@ -62,13 +62,13 @@ class MainWindow(wx.Frame, QuickApp):
#sizer
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self.sizer)
#Frame elements
self.contact_list = ContactList(self, self)
self.contact_list.registerActivatedCB(self.onContactActivated)
self.contact_list.Hide()
self.sizer.Add(self.contact_list, 1, flag=wx.EXPAND)
self.chat_wins=ChatList(self)
self.CreateStatusBar()
@ -80,12 +80,12 @@ class MainWindow(wx.Frame, QuickApp):
self.tools.AddSeparator()
self.statusTxt=wx.TextCtrl(self.tools, -1, style = wx.TE_PROCESS_ENTER)
self.tools.AddControl(self.statusTxt)
self.Bind(wx.EVT_COMBOBOX, self.onStatusChange, self.statusBox)
self.Bind(wx.EVT_COMBOBOX, self.onStatusChange, self.statusBox)
self.Bind(wx.EVT_TEXT_ENTER, self.onStatusChange, self.statusTxt)
self.tools.Disable()
#tray icon
ticon = wx.Icon(os.path.join(self.media_dir, 'icons/crystal/tray_icon.xpm'), wx.BITMAP_TYPE_XPM)
self.tray_icon = wx.TaskBarIcon()
@ -95,16 +95,16 @@ class MainWindow(wx.Frame, QuickApp):
#events
self.Bind(wx.EVT_CLOSE, self.onClose, self)
#menus
self.createMenus()
for i in range(self.menuBar.GetMenuCount()):
self.menuBar.EnableTop(i, False)
#profile panel
self.profile_pan = ProfileManager(self)
self.profile_pan = ProfileManager(self)
self.sizer.Add(self.profile_pan, 1, flag=wx.EXPAND)
self.postInit()
self.Show()
@ -195,7 +195,7 @@ class MainWindow(wx.Frame, QuickApp):
popup.SetPosition((x,0))
popup.Show()
wx.CallLater(5000,popup.Destroy)
def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None):
if type == 'info':
flags = wx.OK | wx.ICON_INFORMATION
@ -212,7 +212,7 @@ class MainWindow(wx.Frame, QuickApp):
if answer_cb:
data = [answer_data] if answer_data else []
answer_cb(True if (answer == wx.ID_YES or answer == wx.ID_OK) else False, *data)
def setStatusOnline(self, online=True):
"""enable/disable controls, must be called when local user online status change"""
if online:
@ -241,12 +241,12 @@ class MainWindow(wx.Frame, QuickApp):
if filename:
answer_data["dest_path"] = filename
self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile)
self.waitProgress(confirmation_id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), profile)
self.waitProgress(confirmation_id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), profile)
else:
answer = wx.ID_NO
if answer==wx.ID_NO:
self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile)
dlg.Destroy()
elif confirmation_type == "YES/NO":
@ -323,21 +323,21 @@ class MainWindow(wx.Frame, QuickApp):
if not self.pbar:
#first answer, we must construct the bar
self.pbar = wx.ProgressDialog(title, message, float(data['size']), None,
wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME)
wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME)
self.pbar.finish_value = float(data['size'])
self.pbar.Update(int(data['position']))
elif self.pbar:
self.pbar.Update(self.pbar.finish_value)
return
wx.CallLater(10, self.progressCB, progress_id, title, message, profile)
def waitProgress (self, progress_id, title, message, profile):
self.pbar = None
wx.CallLater(10, self.progressCB, progress_id, title, message, profile)
### events ###
@ -388,7 +388,7 @@ class MainWindow(wx.Frame, QuickApp):
def onExit(self, e):
self.Close()
def onAddContact(self, e):
debug(_("Add contact request"))
dlg = wx.TextEntryDialog(
@ -439,15 +439,15 @@ class MainWindow(wx.Frame, QuickApp):
dlg.ShowModal()
dlg.Destroy()
return
_id = self.bridge.getCard(target.short, profile_key=self.profile)
_id = self.bridge.getCard(target.short, profile_key=self.profile)
self.current_action_ids.add(_id)
self.current_action_ids_cb[_id] = self.onProfileReceived
def onProfileReceived(self, data):
"""Called when a profile is received"""
debug (_('Profile received: [%s]') % data)
profile=Profile(self, data)
def onJoinRoom(self, e):
warning('FIXME: temporary menu, must be improved')
#TODO: a proper MUC room joining dialog with nickname etc
@ -473,7 +473,7 @@ class MainWindow(wx.Frame, QuickApp):
target = data['__private__']['target']
del data['__private__']
gatewayManager = GatewaysManager(self, data, server=target)
def onClose(self, e):
QuickApp.onExit(self)
info(_("Exiting..."))
@ -489,4 +489,4 @@ class MainWindow(wx.Frame, QuickApp):
self.Show()
self.Raise()
e.Skip()

View file

@ -42,15 +42,15 @@ class Param(wx.Frame):
self.sizer.Add(self.notebook, 1, flag=wx.EXPAND)
self.SetSizer(self.sizer)
self.SetAutoLayout(True)
#events
self.Bind(wx.EVT_CLOSE, self.onClose, self)
self.MakeModal()
for category in self.host.bridge.getParamsCategories():
self.addCategory(category)
self.Show()
def addCategory(self, category):
@ -62,7 +62,7 @@ class Param(wx.Frame):
def gotParams(result):
cat_dom = minidom.parseString(result.encode('utf-8'))
for param in cat_dom.documentElement.getElementsByTagName("param"):
name = param.getAttribute("name")
label = param.getAttribute("label")
@ -109,20 +109,20 @@ class Param(wx.Frame):
def onTextChanged(self, event):
"""Called when a string paramater is modified"""
self.modified[event.GetEventObject().param_id]=event.GetString()
### FIXME # Some hacks for better presentation, should be generic # FIXME ###
if event.GetEventObject().param_id == ('JabberID', 'Connection'):
domain = JID(event.GetString()).domain
self.ctl_list[('Server', 'Connection')].SetValue(domain)
self.modified[('Server', 'Connection')] = domain
self.modified[('Server', 'Connection')] = domain
event.Skip()
def onCheckBoxClicked(self, event):
"""Called when a bool paramater is modified"""
self.modified[event.GetEventObject().param_id]="true" if event.GetEventObject().GetValue() else "false"
event.Skip()
def onButtonClicked(self, event):
"""Called when a button paramater is modified"""
self.__save_parameters()

View file

@ -47,24 +47,24 @@ class Profile(wx.Frame):
self.sizer.Add(self.notebook, 1, flag=wx.EXPAND)
self.SetSizer(self.sizer)
self.SetAutoLayout(True)
#events
self.Bind(wx.EVT_CLOSE, self.onClose, self)
self.MakeModal()
self.showData(data)
self.Show()
def showData(self, data):
flags = wx.TE_READONLY
#General tab
generaltab = wx.Panel(self.notebook)
sizer = wx.FlexGridSizer(cols=2)
sizer.AddGrowableCol(1)
generaltab.SetSizer(sizer)
generaltab.SetAutoLayout(True)
for field in ['fullname','nick', 'birthday', 'phone', 'website', 'email']:
for field in ['fullname','nick', 'birthday', 'phone', 'website', 'email']:
value = data[field] if data.has_key(field) else ''
label=wx.StaticText(generaltab, -1, self.name_dict[field]+": ")
sizer.Add(label)
@ -80,7 +80,7 @@ class Profile(wx.Frame):
sizer.Add(self.ctl_list['avatar'], 0)
self.notebook.AddPage(generaltab, _("General"))

View file

@ -56,7 +56,7 @@ class ProfileManager(wx.Panel):
self.sizer.Add(button_panel, flag=wx.CENTER)
self.Bind(wx.EVT_BUTTON, self.onNewProfile, button_new)
self.Bind(wx.EVT_BUTTON, self.onDeleteProfile, button_del)
login_box = wx.StaticBox(self, -1, _("Login"))
self.login_sizer = wx.StaticBoxSizer(login_box, wx.VERTICAL)
self.sizer.Add(self.login_sizer, 1, wx.EXPAND | wx.ALL)
@ -66,13 +66,13 @@ class ProfileManager(wx.Panel):
self.login_pass = wx.TextCtrl(self, -1, style = wx.TE_PASSWORD)
self.login_sizer.Add(wx.StaticText(self, -1, _("Password:")), 0, flag=wx.ALIGN_CENTER)
self.login_sizer.Add(self.login_pass, flag=wx.EXPAND)
loggin_button = wx.Button(self, -1, _("Connect"))
self.Bind(wx.EVT_BUTTON, self.onConnectButton, loggin_button)
self.login_sizer.Add(loggin_button, flag=wx.ALIGN_CENTER)
self.sizer.Add(wx.Window(self, -1), 1)
#Now we can set the default value
self.__setDefault()
@ -82,7 +82,7 @@ class ProfileManager(wx.Panel):
if profile_default:
self.profile_name.SetValue(profile_default)
self.onProfileChange(None)
def __refillProfiles(self):
"""Update profiles with current names. Must be called after a profile change"""
self.profile_name.Clear()
@ -90,8 +90,8 @@ class ProfileManager(wx.Panel):
profiles.sort()
for profile in profiles:
self.profile_name.Append(profile)
def onNewProfile(self, event):
dlg = wx.TextEntryDialog(self, _("Please enter the new profile name"), _("New profile"), style = wx.OK | wx.CANCEL)
if dlg.ShowModal() == wx.ID_OK:
@ -104,7 +104,7 @@ class ProfileManager(wx.Panel):
self.__refillProfiles()
self.profile_name.SetValue(name)
dlg.Destroy()
def onDeleteProfile(self, event):
name = self.profile_name.GetValue()
if not name:
@ -136,12 +136,12 @@ class ProfileManager(wx.Panel):
return
profile = self.host.bridge.getProfileName(name)
assert(profile)
self.host.bridge.asyncGetParamA("JabberID", "Connection", profile_key=profile, callback=lambda old_jid: self.__old_jidReceived(old_jid, profile), errback=self.getParamError)
def __old_jidReceived(self, old_jid, profile):
self.host.bridge.asyncGetParamA("Password", "Connection", profile_key=profile, callback=lambda old_pass: self.__old_passReceived(old_jid, old_pass, profile), errback=self.getParamError)
def __old_passReceived(self, old_jid, old_pass, profile):
new_jid = self.login_jid.GetValue()
new_pass = self.login_pass.GetValue()
@ -153,7 +153,7 @@ class ProfileManager(wx.Panel):
debug(_('Saving new password'))
self.host.bridge.setParam("Password", new_pass, "Connection", profile)
self.host.plug_profile(profile)
def getParamError(self, ignore):
wx.MessageDialog(self, _("Can't get profile parameter"), _("Profile error"), wx.ICON_ERROR).ShowModal()

View file

@ -49,17 +49,17 @@ class GraphicElement():
def __cmp__(self, other):
return self.zindex.__cmp__(other.zindex)
def draw(self, dc, x=None, y=None):
"""Draw the card on the device context
@param dc: device context
@param x: abscissa
@param x: abscissa
@param y: ordinate"""
dc.DrawBitmap(self.bitmap, x or self.x, y or self.y, self.transparent)
class BaseWindow(wx.Window):
"""This is the panel where the game is drawed, under the other widgets"""
def __init__(self, parent):
wx.Window.__init__(self, parent, pos=(0,0), size=(WIDTH, HEIGHT))
self.parent = parent
@ -98,7 +98,7 @@ class BaseWindow(wx.Window):
for i in range(4):
answer = self.parent.players_data[i]["answer"]
score = self.parent.players_data[i]["score"]
if answer == None:
if answer == None:
device_context.DrawText("%d" % score, 100 + i*184, 355)
else:
device_context.DrawBitmap(self.right_image if answer else self.wrong_image, 39+i*184, 348, True)
@ -118,14 +118,14 @@ class BaseWindow(wx.Window):
if left:
#we now draw the timer
angle = ((-2*pi)*((total-left)/total) + (pi/2))
x = center_x + radius * cos(angle)
x = center_x + radius * cos(angle)
y = center_y - radius * sin(angle)
device_context.DrawArc(center_x, center_y-radius, x, y, center_x, center_y)
def onPaint(self, event):
dc = wx.PaintDC(self)
self.fullPaint(dc)
class QuizPanel(wx.Panel):
@ -156,7 +156,7 @@ class QuizPanel(wx.Panel):
self.answer.Bind(wx.EVT_TEXT_ENTER, self.answered)
self.parent.host.bridge.quizGameReady(player_nick, referee, profile_key = self.parent.host.profile)
self.state = None
def answered(self, event):
"""Called when the player gave an answer in the box"""
self.last_answer = self.answer.GetValue()
@ -184,7 +184,7 @@ class QuizPanel(wx.Panel):
self.time_limit = self.time_origin + timer
self.time_pause = None
self.__timer_refresh()
def __timer_refresh(self):
self.Refresh()
if self.time_left:
@ -203,14 +203,14 @@ class QuizPanel(wx.Panel):
self.startTimer(timer)
self.last_answer = None
self.answer.Clear()
def quizGamePlayerBuzzed(self, player, pause):
"""Called when the player pushed the buzzer
@param player: player who pushed the buzzer
@param pause: should we stop the timer ?"""
if pause:
self.time_pause = time()
def quizGamePlayerSays(self, player, text, delay):
"""Called when the player says something
@param player: who is talking

View file

@ -25,7 +25,7 @@ from sat_frontends.bridge.DBus import DBusBridgeFrontend
import pdb
import logging
from logging import debug, info, error
from sat_frontends.wix.main_window import MainWindow
from sat_frontends.wix.main_window import MainWindow
### logging configuration FIXME: put this elsewhere ###
logging.basicConfig(level=logging.DEBUG,

View file

@ -43,11 +43,11 @@ class XMLUI(wx.Frame):
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self.sizer)
self.SetAutoLayout(True)
#events
if not 'NO_CANCEL' in self.options:
self.Bind(wx.EVT_CLOSE, self.onClose, self)
self.MakeModal()
self.constructUI(xml_data)
@ -83,7 +83,7 @@ class XMLUI(wx.Frame):
elif type=="password":
ctrl = wx.TextCtrl(parent, -1, value, style=wx.TE_PASSWORD)
self.ctrl_list[name] = ({'type':type, 'control':ctrl})
_proportion = 1
_proportion = 1
elif type=="textbox":
ctrl = wx.TextCtrl(parent, -1, value, style=wx.TE_MULTILINE)
self.ctrl_list[name] = ({'type':type, 'control':ctrl})
@ -142,12 +142,12 @@ class XMLUI(wx.Frame):
if parent:
parent.sizer.Add(current, _proportion, flag=wx.EXPAND)
elif node.nodeName == "category":
name = node.getAttribute('name')
label = node.getAttribute('label')
name = node.getAttribute('name')
label = node.getAttribute('label')
if not node.nodeName in wanted or not name or not isinstance(parent,wx.Notebook):
raise Exception("Invalid XMLUI") #TODO: make a custom exception
notebook = parent
tab_panel = wx.Panel(notebook, -1)
tab_panel = wx.Panel(notebook, -1)
tab_panel.sizer = wx.BoxSizer(wx.VERTICAL)
tab_panel.SetSizer(tab_panel.sizer)
notebook.AddPage(tab_panel, label or name)
@ -162,7 +162,7 @@ class XMLUI(wx.Frame):
def constructUI(self, xml_data):
panel=wx.Panel(self)
panel.sizer = wx.BoxSizer(wx.VERTICAL)
cat_dom = minidom.parseString(xml_data.encode('utf-8'))
top= cat_dom.documentElement
self.type = top.getAttribute("type")
@ -230,13 +230,13 @@ class XMLUI(wx.Frame):
warning (_("The form data is not sent back, the type is not managed properly"))
self.MakeModal(False)
self.Destroy()
def onFormCancelled(self, event):
"""Called when cancel button is clicked"""
debug(_("Cancelling form"))
self.MakeModal(False)
self.Close()
def onClose(self, event):
"""Close event: we have to send the form."""
debug(_("close"))