-
-
Notifications
You must be signed in to change notification settings - Fork 341
/
__main__.py
90 lines (64 loc) · 2.38 KB
/
__main__.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /usr/bin/env python3
"""
pyWhat: Identify Anything.
"""
import platform
import sys
import what
import threading
from PyQt6.QtCore import QSize, Qt
from PyQt6.QtGui import QAction
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QLabel, QLineEdit, QVBoxLayout, QWidget, QMenu, QCheckBox
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("PyWhat-GUI")
# self.label = QLabel("Enter Phrase Here")
# font = self.label.font()
# font.setPointSize(16)
# self.label.setFont(font)
# self.label.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter)
self.input = QLineEdit()
self.input.setPlaceholderText("Enter your phrase here.")
self.input.returnPressed.connect(self.searchThis)
button = QPushButton("PyWhat Me!")
button.setCheckable(True)
button.clicked.connect(self.searchThis)
layout = QVBoxLayout()
# layout.addWidget(self.label)
layout.addWidget(self.input)
layout.addWidget(button)
self.container = QWidget()
self.container.setLayout(layout)
self.setFixedSize(QSize(400, 300))
# Set the central widget of the Window.
self.setCentralWidget(self.container)
def searchThis(self):
# print("Clicked!")
search = self.input.text()
# print(self.input.text())
# sys.stdout = open('out.dat', 'w')
result = what.run({search})
print("result", result)
# sys.stdout.close()
# def contextMenuEvent(self, e):
# context = QMenu(self)
# context.addAction(QAction("test 1", self))
# context.addAction(QAction("test 2", self))
# context.addAction(QAction("test 3", self))
# context.exec(e.globalPos())
if __name__ == "__main__":
if sys.version_info < (3, 6):
print(
f"What requires Python 3.6+, you are using {platform.python_version()}. Please install a higher Python version."
)
sys.exit(1)
# from pywhat import what
app = QApplication(sys.argv)
global window
window = MainWindow()
window.show()
app.exec()
# if len(sys.argv) == 1:
# what.main(["--help"])
# what.main()