# Python 3. PyQt4
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui, QtCore
# ГРАФИКА
class Window(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.resize(400, 150) # шир / выс окна
# ПЕРЕМЕННЫЕ КЛАССА
#self.sel_text = ''
self.sel_text_lst = []
# БЛОК РАЗМЕТКИ
self.vbox = QtGui.QVBoxLayout()
# ---
self.pole_vvod = QtGui.QLineEdit('djf j.f ndsf ndk adf')
self.pole_vvod.selectionChanged.connect(self.tx)
self.vbox.addWidget(self.pole_vvod)
# ---
self.btn = QtGui.QPushButton('Пуск')
self.btn.clicked.connect(self.on_click)
self.vbox.addWidget(self.btn)
# ---
self.setLayout(self.vbox)
# ---
# ЛОГИКА
def tx(self):
self.sel_text = self.pole_vvod.selectedText()
#print(self.sel_text)
self.sel_text_lst.insert(0,self.sel_text)
if len(self.sel_text_lst) > 2:
self.sel_text_lst.pop(2)
def on_click(self):
#text = self.sel_text
text = self.sel_text_lst[1]
print(text)
# КОНЕЦ
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
# Python 3
# -*- coding: utf-8 -*-
import sys, importlib
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import (QWidget, qApp, QAction, QApplication, QHBoxLayout, QVBoxLayout,
QGridLayout, QLabel, QLineEdit, QTextEdit, QPushButton, QComboBox,
QCheckBox, QRadioButton, QFrame, QScrollArea, QTabWidget, QSizePolicy,
QGroupBox, QFileDialog)
from PyQt4.QtGui import QIcon, QPixmap, QPalette, QTextCursor
from PyQt4.QtCore import QSize
# ЦВЕТА ПОЛЕЙ
sss_vivod = ("background-color: #456173; color: #f2f2f0; font: 14pt 'Courier New'")
def dynamic_import(module):
return importlib.import_module(module)
# ГРАФИКА
class Window(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.resize(300, 200) # шир / выс окна
self.setWindowTitle('Заголовок') # Заголовок
# БЛОК РАЗМЕТКИ
self.vbox = QtGui.QVBoxLayout()
# ---
self.pole_vivod = QtGui.QTextEdit('')
self.pole_vivod.setStyleSheet(sss_vivod)
self.vbox.addWidget(self.pole_vivod)
# ---
self.box = QComboBox()
self.box.addItems(['a','b1'])
self.box.activated[str].connect(self.on_start)
self.vbox.addWidget(self.box)
# ---
self.setLayout(self.vbox)
# ---
Window.on_start(self)
# ЛОГИКА
def on_start(self):
name_modul = self.box.currentText()
# print('name_modul = ',name_modul)
mod = dynamic_import(name_modul)
#print(mod.p)
self.pole_vivod.setText(str(mod.p))
# КОНЕЦ
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
window.show() # запускает окно
sys.exit(app.exec_())
p = ['few','efwg']
p = [2,234,214]
def on_click_7(self):
def aps(i):
i = ''.join(map(str, i))
data.append(str(i))
data = []
self.pole_vivod.clear() # очистка поля вывода
aps(['<table border ALIGN=CENTER WIDTH=95%>'])
for i in d:
aps(['<tr>'])
for j in i:
aps(['<td ALIGN=CENTER>'+str(j)+'</td>'])
aps(['</tr>'])
aps(['</table>'])
data = ''.join(map(str, data)) # объединение списка
self.pole_vivod.append(data)