Added an example for PyQt5 (#389)
* added pyqt5 example * fixed example path on build * improved pyqt example * simplified example
This commit is contained in:
+1
-1
@@ -308,7 +308,7 @@ export(TARGETS ${QTERMWIDGET_LIBRARY_NAME}
|
||||
|
||||
# example application
|
||||
if(BUILD_EXAMPLE)
|
||||
set(EXAMPLE_SRC example/main.cpp)
|
||||
set(EXAMPLE_SRC examples/cpp/main.cpp)
|
||||
add_executable(example ${EXAMPLE_SRC})
|
||||
target_link_libraries(example ${QTERMWIDGET_LIBRARY_NAME})
|
||||
endif()
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
here is sample program which uses QTermWidet for displaying a terminal
|
||||
@@ -0,0 +1 @@
|
||||
Here are two sample programs which use QTermWidget for displaying a terminal
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/python3
|
||||
from PyQt5 import QtWidgets
|
||||
from QTermWidget import QTermWidget
|
||||
|
||||
|
||||
class Terminal(QTermWidget):
|
||||
def __init__(self, process: str, args: list):
|
||||
super().__init__(0)
|
||||
self.finished.connect(self.close)
|
||||
self.setTerminalSizeHint(False)
|
||||
self.setColorScheme("DarkPastels")
|
||||
self.setShellProgram(process)
|
||||
self.setArgs(args)
|
||||
self.startShellProgram()
|
||||
self.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QtWidgets.QApplication([])
|
||||
args = ["--clean", "--noplugin"]
|
||||
term = Terminal("vim", args)
|
||||
app.exec()
|
||||
Reference in New Issue
Block a user