class worker( QThread ):
new_signal = pyqtSignal( str, dict )
def __init__(self, result, parent=None, signal=None ):
super().__init__()
self.result = result
self.parent = parent
self.signal = signal
@pyqtSlot( str, dict )
def slave( self, token, value ):
for token, value in self.result.items():
f_username = QFrame()
f_username.setStyleSheet('background-color: red;')
self.signal.emit( token, value, [f_username] )
class ui_resultpanel( QObject ):
old_signal = pyqtSignal( str, dict, list )
def __init__(self, parent, result ):
super().__init__()
self.result = result
self.current_result = {}
self.parent = parent
self.row = 0
self.setupUI()
self.old_signal.connect( self.slave )
self.worker = worker( self.result, self.parent, self.old_signal )
self.worker.new_signal.connect( self.worker.slave )
def setupUI( self ):
try:
self.frame = QFrame( self.parent )
self.frame.setGeometry( 45, 0, 955, 400 )
self.inittable()
self.initpanel()
except Exception:
pass
def inittable( self ):
try:
table = QTableWidget( self.frame )
table.setGeometry( 0, 0, 955, 300 )
table.setColumnCount(8)
table.setColumnWidth(0, 160)
table.setColumnWidth(1, 160)
table.setColumnWidth(2, 50)
table.setColumnWidth(3, 110)
table.setColumnWidth(4, 38)
table.setColumnWidth(5, 125)
table.setColumnWidth(6, 38)
table.setColumnWidth(7, 228)
table.setMaximumHeight( 400 )
table.setHorizontalHeaderLabels( ["username","email","locale","verified","rate","canBuy","productID","token"] )
self.table = table
self.table.setRowCount( 0 )
except Exception:
pass
@pyqtSlot( str, dict, list )
def slave( self, token, value, frames ):
self.table.setRowCount( self.table.rowCount() + 1 )
self.table.setItem( self.row, 0, QTableWidgetItem( value['username'] ) )
self.table.setItem( self.row, 1, QTableWidgetItem( value['email'] ) )
block_username = frames[0]
self.table.setCellWidget( self.row, 2, block_username )
self.row += 1
def sort( self ):
try:
for token, value in self.result.items():
self.worker.new_signal.emit( token, value )
except Exception as e:
print( e )
def loadGIF( self, parent, path_to_gif, width=30, height=30 ):
try:
if os.path.exists( path_to_gif ):
movie = QMovie( path_to_gif )
lb = QLabel( parent )
lb.setMovie( movie )
lb.setScaledContents( True )
lb.setFixedSize( width, height )
movie.start()
return lb
except Exception:
pass
def loadAvatar( self, parent, url ):
try:
ua = UserAgent()
header = {'User-Agent' : ua.chrome}
data = requests.get(url, headers=header)
if data.status_code == 200:
data = data.content
pixmap = QPixmap()
pixmap.loadFromData(data)
lb = QLabel( parent )
lb.setPixmap( pixmap )
lb.setScaledContents( True )
lb.setFixedSize( 30, 30 )
return lb
else:
lb = QLabel( parent )
lb.setPixmap( QPixmap( self.icons['unknown_avatar'] ) )
lb.setScaledContents( True )
lb.setFixedSize( 30, 30 )
return lb
except Exception:
lb = QLabel( parent )
lb.setPixmap( QPixmap( self.icons['unknown_avatar'] ) )
lb.setScaledContents( True )
lb.setFixedSize( 30, 30 )
return lb
def loadFlag( self, parent, locale ):
try:
if locale in self.located:
country_data = self.located[ locale ]
country_name = country_data['country_name']
icon = country_data['path_to_icon']
lb = QLabel( parent )
lb.setPixmap( QPixmap(icon) )
lb.setScaledContents( True )
lb.setFixedSize( 30, 20 )
lb.move( 9, 5 )
lb.setToolTip( country_name )
return lb
else:
icon = os.path.join( path_to_flags_folder, 'missing_flag.png' )
lb = QLabel( parent )
lb.setPixmap( QPixmap(icon) )
lb.setScaledContents( True )
lb.setFixedSize( 30, 20 )
lb.move( 9, 5 )
lb.setToolTip( 'Unknown Country' )
return lb
except Exception:
pass
def initpanel( self ):
try:
frame = QFrame( self.frame )
frame.setObjectName('statusbar-showpanel')
frame.setGeometry( 0, 300, 955, 100 )
fr_filter = QFrame( frame )
fr_filter.setObjectName('statusbar-showpanel-filter')
fr_filter.setGeometry( 10, 10, 500, 35 )
check_btn_email = QCheckBox( frame )
check_btn_email.setText('Email Verified')
check_btn_email.setChecked( True )
check_btn_email.setObjectName('statusbar-showpanel-lb-filter-item')
check_btn_phone = QCheckBox( frame )
check_btn_phone.setText('Phone Verified')
check_btn_phone.setChecked( True )
check_btn_phone.setObjectName('statusbar-showpanel-lb-filter-item')
check_btn_sub = QCheckBox( frame )
check_btn_sub.setText('Sub Enabled')
check_btn_sub.setChecked( True )
check_btn_sub.setObjectName('statusbar-showpanel-lb-filter-item')
check_btn_canBuy = QCheckBox( frame )
check_btn_canBuy.setText('CanBuy')
check_btn_canBuy.setChecked( True )
check_btn_canBuy.setObjectName('statusbar-showpanel-lb-filter-item')
check_btn_isRegister = QCheckBox( frame )
check_btn_isRegister.setText('Registered')
check_btn_isRegister.setChecked( True )
check_btn_isRegister.setObjectName('statusbar-showpanel-lb-filter-item')
check_btn_rate = QCheckBox( frame )
check_btn_rate.setText('High Rate')
check_btn_rate.setChecked( True )
check_btn_rate.setObjectName('statusbar-showpanel-lb-filter-item')
layout = QHBoxLayout( fr_filter )
layout.addWidget( check_btn_email )
layout.addWidget( check_btn_phone )
layout.addWidget( check_btn_sub )
layout.addWidget( check_btn_canBuy )
layout.addWidget( check_btn_isRegister )
layout.addWidget( check_btn_rate )
btn_search = QPushButton( frame )
btn_search.setText('Search')
btn_search.setGeometry( 10, 45, 200, 30 )
btn_search.setObjectName('statusbar-showpanel-btn-search')
btn_search.setCursor( QCursor( Qt.PointingHandCursor ) )
self.btn_search = btn_search
@btn_search.clicked.connect
def click():
self.sort()
except Exception:
pass
def clear_rows( self ):
try:
for i in reversed(range(self.table.rowCount())):
self.table.removeRow(i)
except Exception:
pass
app = APP()
window = app.window
ui_panel = ui_resultpanel( window, result )
app.run()