def SetValue(self, row, col, value):
     # print 'Update to', value, row, col
     if value != '':
         value = value.split()
         value = filter(None, value)
         if value[0] == 'LUNCH':
             if len(value) > 1:
                 name = self.name + '-' + value[1]
             else:
                 name = self.name
             try:
                 project.insert_lunch(name, row, col, self.type)
                 pub.sendMessage('UPDATE_VIEW', data=None)
             except Exception as e:
                 s = 'Conflict with: '
                 for t in e.value:
                     for e in t:
                         if e != None:
                             s += str(e) + ' '
                     s += '\n'
                 dlg = wx.MessageDialog(None, s, "ERROR",
                                        wx.OK | wx.ICON_INFORMATION)
                 dlg.ShowModal()
                 dlg.Destroy()
                 return
         else:
             if len(value) >= 3:
                 if self.type == 'Teacher':
                     t = self.name
                     v = value[0]
                     c = value[1]
                     s = value[2]
                     i = row
                     j = col
                     if len(value) == 4:
                         t += '-' + value[3]
                 if self.type == 'Venue':
                     t = value[0]
                     v = self.name
                     c = value[1]
                     s = value[2]
                     i = row
                     j = col
                     if len(value) == 4:
                         v += '-' + value[3]
                 if self.type == 'Class':
                     t = value[0]
                     v = value[1]
                     c = self.name
                     s = value[2]
                     i = row
                     j = col
                     if len(value) == 4:
                         c += '-' + value[3]
                 try:
                     project.insert_entry(t, v, c, s, i, j)
                     pub.sendMessage('UPDATE_VIEW', data=None)
                 except Exception as e:
                     # print e
                     s = 'Conflict with: '
                     for t in e.value:
                         for e in t:
                             if e != None:
                                 s += str(e) + ' '
                         s += '\n'
                     dlg = wx.MessageDialog(None, s, "ERROR",
                                            wx.OK | wx.ICON_INFORMATION)
                     dlg.ShowModal()
                     dlg.Destroy()
Пример #2
0
    def OnLunchClick(self, i, j, evt):
        print i, j
        self.dia = wx.Dialog(self, -1, 'Enter Lunch Details', size=(300,50))
        self.dia.mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.dia.mainSizer.AddSpacer(10)

        if self.type == "Class":
            self.dia.label1 = wx.StaticText(self.dia, label='Enter Class:')
            # self.dia.field1 = wx.TextCtrl(self.dia, value="")
            self.dia.field1 = PromptingComboBox(self.dia, "Choose", globaldata.class_shortnames[1:], 'Class') 
        elif self.type == "Teacher":
            self.dia.label1 = wx.StaticText(self.dia, label='Enter Teacher:')
            # self.dia.field1 = wx.TextCtrl(self.dia, value="")
            self.dia.field1 = PromptingComboBox(self.dia, "Choose", globaldata.teacher_shortnames[1:], 'Teacher') 

        self.dia.field1.SetValue(self.name)
        self.dia.field1.res = self.name
        self.dia.mainSizer.Add(self.dia.label1, 1, flag=wx.ALIGN_CENTER_VERTICAL)
        self.dia.mainSizer.Add(self.dia.field1, 1, flag=wx.ALIGN_CENTER_VERTICAL)

        self.dia.okbutton = wx.Button(self.dia, label="OK", id=wx.ID_OK)
        self.dia.mainSizer.Add(self.dia.okbutton, 1, flag=wx.ALIGN_CENTER_VERTICAL)
        self.dia.mainSizer.AddSpacer(10)
        self.dia.okbutton.SetFocus()        
        self.dia.SetSizer(self.dia.mainSizer)
        self.dia.result = None
        self.dia.Bind(wx.EVT_BUTTON, self.onOK, id=wx.ID_OK)
        self.dia.Bind(wx.EVT_TEXT_ENTER, self.onOK)
        self.dia.Bind(wx.EVT_CLOSE, self.Closed)
        self.dia.ShowModal()

        if hasattr(self.dia, 'result1'):
            if self.GetCellSize(i,j) == (1,1):
                try:
                    print 'lunch', self.dia.result1
                    project.insert_lunch(self.dia.result1, i, j, self.type)
                    pub.sendMessage('UPDATE_VIEW', data = None)
                except Exception as e:
                    s = 'Conflict with: '
                    for t in e.value:
                        for e in t:
                            if e != None:
                                s += str(e) + ' '
                        s += '\n'
                    dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                    dlg.ShowModal()
                    dlg.Destroy()
            else:
                x, y = self.GetCellSize(i,j)
                l = i
                m = j
                for i in range(x):
                    for j in range(y):
                        p = l+i
                        q = m+j
                        try:
                            project.insert_lunch(self.dia.result1, p, q, self.type)
                            pub.sendMessage('UPDATE_VIEW', data = None)
                        except Exception as e:
                            print e
                            s = 'Conflict with: '
                            for t in e.value:
                                for e in t:
                                    if e != None:
                                        s += str(e) + ' '
                                s += '\n'
                            dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                            dlg.ShowModal()
                            dlg.Destroy()
                            self.SetCellSize(l, m, 1,1)
        evt.Skip()
 def SetValue(self, row, col, value):
     # print 'Update to', value, row, col
     if value != '':
         value = value.split()
         value = filter(None, value)
         if value[0] == 'LUNCH':
             if len(value) > 1:
                 name = self.name + '-' + value[1]
             else:
                 name = self.name
             try:
                 project.insert_lunch(name, row, col, self.type)
                 pub.sendMessage('UPDATE_VIEW', data = None)
             except Exception as e:
                 s = 'Conflict with: '
                 for t in e.value:
                     for e in t:
                         if e != None:
                             s += str(e) + ' '
                     s += '\n'
                 dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                 dlg.ShowModal()
                 dlg.Destroy()
                 return
         else:
             if len(value) >= 3:
                 if self.type == 'Teacher':
                     t = self.name
                     v = value[0]
                     c = value[1]
                     s = value[2]
                     i = row
                     j = col
                     if len(value) == 4:
                         t += '-' + value[3]
                 if self.type == 'Venue':
                     t = value[0]
                     v = self.name
                     c = value[1]
                     s = value[2]
                     i = row
                     j = col
                     if len(value) == 4:
                         v += '-' + value[3]
                 if self.type == 'Class':
                     t = value[0] 
                     v = value[1]
                     c = self.name
                     s = value[2]
                     i = row
                     j = col
                     if len(value) == 4:
                         c += '-' + value[3]
                 try:
                     project.insert_entry(t, v, c, s, i, j)
                     pub.sendMessage('UPDATE_VIEW', data = None)
                 except Exception as e:
                     # print e
                     s = 'Conflict with: '
                     for t in e.value:
                         for e in t:
                             if e != None:
                                 s += str(e) + ' '
                         s += '\n'
                     dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                     dlg.ShowModal()
                     dlg.Destroy()
Пример #4
0
    def HandelManualInput(self):
        i = self.rowSelect
        j = self.colSelect

        if self.GetCellSize(i, j) == (1,1):
            for e in globaldata.clipboard:
                if len(e) == 3:
                    try:
                        if self.type == 'Class':
                            project.insert_lunch(e[-1], i, j, self.type)
                        elif self.type == 'Teacher':
                            project.insert_lunch(e[0], i, j, self.type)  
                                                      
                        pub.sendMessage('UPDATE_VIEW', data = None)
                    except Exception as e:
                        s = 'Conflict with: '
                        for t in e.value:
                            for e in t:
                                if e != None:
                                    s += str(e) + ' '
                            s += '\n'
                        dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                        dlg.ShowModal()
                        dlg.Destroy()
                else:
                    t = e[0]
                    v = e[1]
                    c = e[2]
                    s = e[3]            
                    try:
                        project.insert_entry(t, v, c, s, i, j)
                        pub.sendMessage('UPDATE_VIEW', data = None)
                    except Exception as e:
                        print e
                        s = 'Conflict with: '
                        for t in e.value:
                            for e in t:
                                if e != None:
                                    s += str(e) + ' '
                            s += '\n'
                        dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                        dlg.ShowModal()
                        dlg.Destroy()

        else:
            p, q = i, j
            x, y = self.GetCellSize(p, q)
            for l in range(x):
                for m in range(y):
                    i = p+l
                    j = q+m

                    for e in globaldata.clipboard:
                        if len(e) == 3:
                            try:
                                if self.type == 'Class':
                                    project.insert_lunch(e[-1], i, j, self.type)
                                elif self.type == 'Teacher':
                                    project.insert_lunch(e[0], i, j, self.type)                                    
                                pub.sendMessage('UPDATE_VIEW', data = None)
                            except Exception as e:
                                s = 'Conflict with: '
                                for t in e.value:
                                    for e in t:
                                        if e != None:
                                            s += str(e) + ' '
                                    s += '\n'
                                dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                                dlg.ShowModal()
                                dlg.Destroy()
                                self.SetCellSize(p, q, 1,1)
                        else:
                            t = e[0]
                            v = e[1]
                            c = e[2]
                            s = e[3]            
                            try:
                                project.insert_entry(t, v, c, s, i, j)
                                pub.sendMessage('UPDATE_VIEW', data = None)
                            except Exception as e:
                                print e
                                s = 'Conflict with: '
                                for t in e.value:
                                    for e in t:
                                        if e != None:
                                            s += str(e) + ' '
                                    s += '\n'
                                dlg = wx.MessageDialog(None, s , "ERROR", wx.OK|wx.ICON_INFORMATION)
                                dlg.ShowModal()
                                dlg.Destroy()
                                self.SetCellSize(p, q, 1,1)
        return