Created
November 8, 2017 04:53
-
-
Save eyllanesc/3d200020db4af413282dc8a96eb732b5 to your computer and use it in GitHub Desktop.
47165998
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import os.path | |
class DownloadItem: | |
def __init__(self, path): | |
self.dirname = os.path.dirname(path) | |
self.filename = os.path.basename(path) | |
self.fullpath = path | |
self.type = "" | |
#----------------- START -----------------------# | |
entries = ('/home/user/video1.mp4', '/home/user/videos/video11.mkv', '/home/user2/my-vacation.avi', \ | |
'/home/user4/training.avi', '/home/user99/bootleg_movie.mkv') | |
Listing = [] | |
for item in entries: | |
obj = DownloadItem(item) | |
Listing.append(obj) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QGroupBox, QDialog, QVBoxLayout, \ | |
QGridLayout | |
from PyQt5.QtCore import pyqtSlot | |
from DirListing import Listing | |
class ButtonTest(QDialog): | |
def __init__(self): | |
super(ButtonTest, self).__init__() | |
self.top = 10 | |
self.left = 10 | |
self.width = 320 | |
self.height = 500 | |
self.initUI() | |
def initUI(self): | |
self.setWindowTitle("Directory Buttons") | |
self.setGeometry(self.left, self.top, self.width, self.height) | |
self.createGridLayout() | |
windowLayout = QVBoxLayout() | |
windowLayout.addWidget(self.horizontalGroupBox) | |
self.setLayout(windowLayout) | |
self.show() | |
def createGridLayout(self): | |
self.horizontalGroupBox = QGroupBox("Joe") | |
layout = QGridLayout() | |
counter = 0 | |
for obj in Listing: | |
button = QPushButton(obj.filename) | |
button.clicked.connect(self.on_click) | |
layout.addWidget(button, counter, 0) | |
counter = counter + 1 | |
self.horizontalGroupBox.setLayout(layout) | |
@pyqtSlot() | |
def on_click(self): | |
print(self.sender().text()) | |
if __name__ == '__main__': | |
app = QApplication(sys.argv) | |
ex = ButtonTest() | |
sys.exit(app.exec_()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QGroupBox, QDialog, QVBoxLayout, \ | |
QGridLayout | |
from PyQt5.QtCore import pyqtSlot | |
from DirListing import Listing | |
class ButtonTest(QDialog): | |
def __init__(self): | |
super(ButtonTest, self).__init__() | |
self.top = 10 | |
self.left = 10 | |
self.width = 320 | |
self.height = 500 | |
self.initUI() | |
def initUI(self): | |
self.setWindowTitle("Directory Buttons") | |
self.setGeometry(self.left, self.top, self.width, self.height) | |
self.createGridLayout() | |
windowLayout = QVBoxLayout() | |
windowLayout.addWidget(self.horizontalGroupBox) | |
self.setLayout(windowLayout) | |
self.show() | |
def createGridLayout(self): | |
self.horizontalGroupBox = QGroupBox("Joe") | |
layout = QGridLayout() | |
counter = 0 | |
for obj in Listing: | |
button = QPushButton(obj.filename) | |
button.clicked.connect(self.on_click) | |
button.setObjectName(obj.filename) | |
layout.addWidget(button, counter, 0) | |
counter = counter + 1 | |
self.horizontalGroupBox.setLayout(layout) | |
@pyqtSlot() | |
def on_click(self): | |
print(self.sender().objectName()) | |
if __name__ == '__main__': | |
app = QApplication(sys.argv) | |
ex = ButtonTest() | |
sys.exit(app.exec_()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QGroupBox, QDialog, QVBoxLayout, \ | |
QGridLayout | |
from PyQt5.QtCore import pyqtSlot | |
from DirListing import Listing | |
class ButtonTest(QDialog): | |
def __init__(self): | |
super(ButtonTest, self).__init__() | |
self.top = 10 | |
self.left = 10 | |
self.width = 320 | |
self.height = 500 | |
self.initUI() | |
def initUI(self): | |
self.setWindowTitle("Directory Buttons") | |
self.setGeometry(self.left, self.top, self.width, self.height) | |
self.createGridLayout() | |
windowLayout = QVBoxLayout() | |
windowLayout.addWidget(self.horizontalGroupBox) | |
self.setLayout(windowLayout) | |
self.show() | |
def createGridLayout(self): | |
self.horizontalGroupBox = QGroupBox("Joe") | |
layout = QGridLayout() | |
counter = 0 | |
for obj in Listing: | |
button = QPushButton(obj.filename) | |
button.clicked.connect(lambda checked, filename=obj.filename: self.on_click(filename)) | |
layout.addWidget(button, counter, 0) | |
counter = counter + 1 | |
self.horizontalGroupBox.setLayout(layout) | |
@pyqtSlot() | |
def on_click(self, filename): | |
print(filename) | |
if __name__ == '__main__': | |
app = QApplication(sys.argv) | |
ex = ButtonTest() | |
sys.exit(app.exec_()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QGroupBox, QDialog, QVBoxLayout, \ | |
QGridLayout, QButtonGroup | |
from PyQt5.QtCore import pyqtSlot | |
from DirListing import Listing | |
class ButtonTest(QDialog): | |
def __init__(self): | |
super(ButtonTest, self).__init__() | |
self.top = 10 | |
self.left = 10 | |
self.width = 320 | |
self.height = 500 | |
self.initUI() | |
def initUI(self): | |
self.setWindowTitle("Directory Buttons") | |
self.setGeometry(self.left, self.top, self.width, self.height) | |
self.createGridLayout() | |
windowLayout = QVBoxLayout() | |
windowLayout.addWidget(self.horizontalGroupBox) | |
self.setLayout(windowLayout) | |
self.show() | |
def createGridLayout(self): | |
self.horizontalGroupBox = QGroupBox("Joe") | |
layout = QGridLayout() | |
counter = 0 | |
group = QButtonGroup(self) | |
for obj in Listing: | |
button = QPushButton(obj.filename) | |
layout.addWidget(button, counter, 0) | |
counter = counter + 1 | |
group.addButton(button, counter) | |
group.buttonClicked[int].connect(self.on_click) | |
group.buttonClicked.connect(self.on_click2) | |
self.horizontalGroupBox.setLayout(layout) | |
@pyqtSlot(int) | |
def on_click(self, i): | |
print("button{}".format(i)) | |
def on_click2(self, btn): | |
print(btn.text()) | |
if __name__ == '__main__': | |
app = QApplication(sys.argv) | |
ex = ButtonTest() | |
sys.exit(app.exec_()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QGroupBox, QDialog, QVBoxLayout, \ | |
QGridLayout | |
from PyQt5.QtCore import pyqtSlot | |
from DirListing import Listing | |
class ButtonTest(QDialog): | |
def __init__(self): | |
super(ButtonTest, self).__init__() | |
self.top = 10 | |
self.left = 10 | |
self.width = 320 | |
self.height = 500 | |
self.initUI() | |
def initUI(self): | |
self.setWindowTitle("Directory Buttons") | |
self.setGeometry(self.left, self.top, self.width, self.height) | |
self.createGridLayout() | |
windowLayout = QVBoxLayout() | |
windowLayout.addWidget(self.horizontalGroupBox) | |
self.setLayout(windowLayout) | |
self.show() | |
def createGridLayout(self): | |
self.horizontalGroupBox = QGroupBox("Joe") | |
layout = QGridLayout() | |
counter = 0 | |
for obj in Listing: | |
button = QPushButton(obj.filename) | |
import functools | |
button.clicked.connect(functools.partial(self.on_click, obj.filename)) | |
layout.addWidget(button, counter, 0) | |
counter = counter + 1 | |
self.horizontalGroupBox.setLayout(layout) | |
def on_click(self, filename): | |
print(filename) | |
if __name__ == '__main__': | |
app = QApplication(sys.argv) | |
ex = ButtonTest() | |
sys.exit(app.exec_()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment