-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcelComboBox.py
More file actions
31 lines (23 loc) · 806 Bytes
/
excelComboBox.py
File metadata and controls
31 lines (23 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
import os
from natsort import natsorted, ns
import xlrd
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QTableWidget, QApplication, QMainWindow, QTableWidgetItem, QFileDialog, QComboBox
#from PyQt5.QtCore import QSettings
class ExcelCombo(QtWidgets.QComboBox):
def __init__(self, path):
super().__init__()
self.populate(path)
def populate(self, path):
print(path)
files = os.listdir(path=path)
files_xls = []
for f in files:
if f.endswith(".xls"):
files_xls.append(f)
sfiles_xls = natsorted(files_xls)
sfiles.insert(0, " -- none selected -- ")
for f in sfiles_xls:
if f[0] != '$':
self.addItem(f)