def on_bt_file2_clicked(self): """ Slot documentation goes here. """ if self.mode == -1: self.textBrowser.append(u'您还没有选择模式!') return self.filename2 = QtGui.QFileDialog.getOpenFileName( self, u"选择文件2", "/home", str("Excel Files (*.xlsx *.xls)")) #如果文件不存在,返回 if not os.path.isfile(self.filename2.__str__()): self.textBrowser.append(u'请选择正确的副表文件!') return self.label_2.setText(u'您选择的文件:' + self.filename2) #得到副表有几个sheet,如果为0则返回为空 num_fu = EXCEL.sheets_numbers(self.filename2.__str__()) if num_fu == 0: self.textBrowser.append(u'您选择的表为空!') return if CONFIGURE.DEBUG: print 'num_fu:', num_fu #self.textBrowser.append('sheet numbers:' + str(num_main)) self.textBrowser.append(u'filename2:' + self.filename2) self.comboBox_sheet_fu_F.clear() #主表第几张sheet,默认是第一张 i = 1 while i <= num_fu: self.comboBox_sheet_fu_F.addItem(str(i)) i = i + 1 #将副表的键值展示出来,如果是行模式,则加入第一行,如果是列模式,则加入第一列 # List = EXCEL.present_comboBox(self.filename2.__str__(), self.mode, self.sheet_fu) # 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个)') #第二个文件 if self.mode == 0: self.mode_row_complete = self.mode_row_complete | 2 elif self.mode == 1: self.mode_col_complete = self.mode_col_complete | 2
def on_bt_file2_clicked(self): """ Slot documentation goes here. """ if self.mode == -1: self.textBrowser.append(u'您还没有选择模式!') return self.filename2 = QtGui.QFileDialog.getOpenFileName(self, u"选择文件2", "/home", str("Excel Files (*.xlsx *.xls)")) #如果文件不存在,返回 if not os.path.isfile(self.filename2.__str__()): self.textBrowser.append(u'请选择正确的副表文件!') return self.label_2.setText(u'您选择的文件:'+self.filename2) #得到副表有几个sheet,如果为0则返回为空 num_fu = EXCEL.sheets_numbers(self.filename2.__str__()) if num_fu == 0: self.textBrowser.append(u'您选择的表为空!') return if CONFIGURE.DEBUG: print 'num_fu:', num_fu #self.textBrowser.append('sheet numbers:' + str(num_main)) self.textBrowser.append(u'filename2:' + self.filename2) self.comboBox_sheet_fu_F.clear() #主表第几张sheet,默认是第一张 i = 1 while i <= num_fu: self.comboBox_sheet_fu_F.addItem(str(i)) i = i+1 #将副表的键值展示出来,如果是行模式,则加入第一行,如果是列模式,则加入第一列 # List = EXCEL.present_comboBox(self.filename2.__str__(), self.mode, self.sheet_fu) # 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个)') #第二个文件 if self.mode == 0: self.mode_row_complete = self.mode_row_complete | 2 elif self.mode == 1: self.mode_col_complete = self.mode_col_complete | 2