def set_comboBox_main_key_mode_init(self): if os.path.isfile(self.filename1.__str__()): #将主表的键值展示出来,如果是行模式,则加入第一行,如果是列模式,则加入第一列 List = EXCEL.present_comboBox(self.filename1.__str__(), self.mode, self.sheet_main) if CONFIGURE.DEBUG: print List #首先清空 self.comboBox_main_key_F.clear() #如果该列表元素是float型,则把小数点后末尾的0去掉 #如果List为空,直接返回 if len(List) == 0: #self.textBrowser.append(u'您选择的主表为空!') return import re for con in List: if CONFIGURE.DEBUG: print con, type(con) if isinstance(con, float) and re.match(r'\d*\.0*$', str(con)): gstr = re.match(r'\d*', str(con)).group() self.comboBox_main_key_F.addItem(gstr) elif isinstance(con, float): self.comboBox_main_key_F.addItem(str(con)) else: self.comboBox_main_key_F.addItem((con)) self.label_key_F.setText( u'您选择的主键是:' + self.comboBox_main_key_F.currentText().__str__() + u'(默认是第1个)')
def set_comboBox_main_key_mode_init(self): if os.path.isfile(self.filename1.__str__()): #将主表的键值展示出来,如果是行模式,则加入第一行,如果是列模式,则加入第一列 List = EXCEL.present_comboBox(self.filename1.__str__(), self.mode, self.sheet_main) if CONFIGURE.DEBUG: print List #首先清空 self.comboBox_main_key_F.clear() #如果该列表元素是float型,则把小数点后末尾的0去掉 #如果List为空,直接返回 if len(List) == 0: #self.textBrowser.append(u'您选择的主表为空!') return import re for con in List: if CONFIGURE.DEBUG: print con, type(con) if isinstance(con, float) and re.match(r'\d*\.0*$', str(con)): gstr = re.match(r'\d*', str(con)).group() self.comboBox_main_key_F.addItem(gstr) elif isinstance(con, float): self.comboBox_main_key_F.addItem(str(con)) else: self.comboBox_main_key_F.addItem((con)) self.label_key_F.setText(u'您选择的主键是:'+self.comboBox_main_key_F.currentText().__str__() + u'(默认是第1个)')
def on_bt_file1_clicked(self): """ Slot documentation goes here. """ if self.mode == -1: self.textBrowser.append(u'您还没有选择模式!') return self.filename1 = QtGui.QFileDialog.getOpenFileName( self, u"选择文件1", "/home", str("Excel Files (*.xlsx *.xls)")) #如果文件不存在,返回 if not os.path.isfile(self.filename1.__str__()): self.textBrowser.append(u'请选择正确的主表文件!') return self.label_1.setText(u'您选择的文件:' + self.filename1) #得到主表有几个sheet,如果为0则返回为空 num_main = EXCEL.sheets_numbers(self.filename1.__str__()) if num_main == 0: self.textBrowser.append(u'您选择的表为空!') return print 'num_main:', num_main #self.textBrowser.append('sheet numbers:' + str(num_main)) self.textBrowser.append(u'filename1:' + self.filename1) self.comboBox_sheet_main_F.clear() #主表第几张sheet,默认是第一张 i = 1 while i <= num_main: self.comboBox_sheet_main_F.addItem(str(i)) i = i + 1 #将主表的键值展示出来,如果是行模式,则加入第一行,如果是列模式,则加入第一列 List = EXCEL.present_comboBox(self.filename1.__str__(), self.mode, self.sheet_main) if CONFIGURE.DEBUG: print List print List #首先清空 self.comboBox_main_key_F.clear() #如果该列表元素是float型,则把小数点后末尾的0去掉 #如果List为空,直接返回 if len(List) == 0: self.textBrowser.append(u'您选择的主表为空!') return import re for con in List: if CONFIGURE.DEBUG: print con, type(con) if isinstance(con, float) and re.match(r'\d*\.0*$', str(con)): gstr = re.match(r'\d*', str(con)).group() self.comboBox_main_key_F.addItem(gstr) elif isinstance(con, float): self.comboBox_main_key_F.addItem(str(con)) else: self.comboBox_main_key_F.addItem((con)) self.label_key_F.setText( u'您选择的主键是:' + self.comboBox_main_key_F.currentText().__str__() + u'(默认是第1个)') #第一个文件 if self.mode == 0: self.mode_row_complete = self.mode_row_complete | 1 elif self.mode == 1: self.mode_col_complete = self.mode_col_complete | 1
def on_bt_file1_clicked(self): """ Slot documentation goes here. """ if self.mode == -1: self.textBrowser.append(u'您还没有选择模式!') return self.filename1 = QtGui.QFileDialog.getOpenFileName(self, u"选择文件1", "/home", str("Excel Files (*.xlsx *.xls)")) #如果文件不存在,返回 if not os.path.isfile(self.filename1.__str__()): self.textBrowser.append(u'请选择正确的主表文件!') return self.label_1.setText(u'您选择的文件:'+self.filename1) #得到主表有几个sheet,如果为0则返回为空 num_main = EXCEL.sheets_numbers(self.filename1.__str__()) if num_main == 0: self.textBrowser.append(u'您选择的表为空!') return print 'num_main:', num_main #self.textBrowser.append('sheet numbers:' + str(num_main)) self.textBrowser.append(u'filename1:' + self.filename1) self.comboBox_sheet_main_F.clear() #主表第几张sheet,默认是第一张 i = 1 while i <= num_main: self.comboBox_sheet_main_F.addItem(str(i)) i = i+1 #将主表的键值展示出来,如果是行模式,则加入第一行,如果是列模式,则加入第一列 List = EXCEL.present_comboBox(self.filename1.__str__(), self.mode, self.sheet_main) if CONFIGURE.DEBUG: print List print List #首先清空 self.comboBox_main_key_F.clear() #如果该列表元素是float型,则把小数点后末尾的0去掉 #如果List为空,直接返回 if len(List) == 0: self.textBrowser.append(u'您选择的主表为空!') return import re for con in List: if CONFIGURE.DEBUG: print con, type(con) if isinstance(con, float) and re.match(r'\d*\.0*$', str(con)): gstr = re.match(r'\d*', str(con)).group() self.comboBox_main_key_F.addItem(gstr) elif isinstance(con, float): self.comboBox_main_key_F.addItem(str(con)) else: self.comboBox_main_key_F.addItem((con)) self.label_key_F.setText(u'您选择的主键是:'+self.comboBox_main_key_F.currentText().__str__() + u'(默认是第1个)') #第一个文件 if self.mode == 0: self.mode_row_complete = self.mode_row_complete | 1 elif self.mode == 1: self.mode_col_complete = self.mode_col_complete | 1