|
| 1 | +# pip install PyQt5 |
| 2 | +# pip install pyshorteners |
| 3 | + |
| 4 | +from PyQt5.QtWidgets import * |
| 5 | +from form import Ui_MainWindow |
| 6 | +import sys |
| 7 | +from pyshorteners import Shortener |
| 8 | + |
| 9 | +class Window(QMainWindow): |
| 10 | + def __init__(self): |
| 11 | + super(Window,self).__init__() |
| 12 | + |
| 13 | + self.ui = Ui_MainWindow() |
| 14 | + self.ui.setupUi(self) |
| 15 | + |
| 16 | + self.setWindowTitle("URL Shortener") |
| 17 | + |
| 18 | + self.ui.make_btn.clicked.connect(self.make_shortlink) |
| 19 | + self.ui.copy_btn.clicked.connect(self.copy_link) |
| 20 | + |
| 21 | + def make_shortlink(self): |
| 22 | + url = self.ui.url.text() |
| 23 | + short_ = Shortener().osdb |
| 24 | + url_short = short_.short(url) |
| 25 | + self.ui.text.setText(url_short) |
| 26 | + def copy_link(self): |
| 27 | + self.ui.text.selectAll() |
| 28 | + self.ui.text.copy() |
| 29 | +def main(): |
| 30 | + app = QApplication(sys.argv) |
| 31 | + app.setApplicationVersion("1") |
| 32 | + win = Window() |
| 33 | + win.show() |
| 34 | + sys.exit(app.exec_()) |
| 35 | + |
| 36 | +if __name__ == '__main__': |
| 37 | + main() |
0 commit comments