-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjoke.py
47 lines (37 loc) · 1.07 KB
/
joke.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3
#
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUi
from googletrans import Translator
import pyjokes
import sys
width = 502
height = 414
class Window(QWidget):
def __init__(self):
super(Window,self).__init__()
loadUi("form.ui",self)
self.setWindowTitle("جک")
self.setGeometry(500,400,width,height)
self.setFixedSize(width,height)
self.btn.clicked.connect(self.joke)
self.clear_btn.clicked.connect(self.clear_joke)
def joke(self):
joke = pyjokes.get_joke()
translator = Translator()
translate = translator.translate(joke,src="en",dest="fa ")
self.text.setText(translate.text)
def clear_joke(self):
self.text.clear()
def main():
app = QApplication(sys.argv)
app.setApplicationName("جک")
app.setApplicationVersion("v1.0")
window = Window()
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
# Joke v1.0
main()