本文整理汇总了Python中src.gui.main_window.Pireal类的典型用法代码示例。如果您正苦于以下问题:Python Pireal类的具体用法?Python Pireal怎么用?Python Pireal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pireal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __on_copy_available
def __on_copy_available(self, value):
""" Change states of cut and copy action """
cut_action = Pireal.get_action("cut_action")
cut_action.setEnabled(value)
copy_action = Pireal.get_action("copy_action")
copy_action.setEnabled(value)
示例2: __init__
def __init__(self):
super(StatusBar, self).__init__()
Pireal.load_service("status", self)
self.connect(self, SIGNAL("messageChanged(QString)"),
self.__message_end)
示例3: execute_queries
def execute_queries(self, query=''):
""" This function executes queries """
# Hide tooltip if visible
if QToolTip.isVisible():
QToolTip.hideText()
# If text is selected, then this text is the query,
# otherwise the query is all text that has the editor
editor_widget = self.currentWidget().get_editor()
if editor_widget.textCursor().hasSelection():
query = editor_widget.textCursor().selectedText()
else:
query = editor_widget.toPlainText()
relations = self.currentWidget().relations
central = Pireal.get_service("central")
table_widget = central.get_active_db().table_widget
# Restore
relations.clear()
self.currentWidget().clear_results()
# Parse query
sc = scanner.Scanner(query)
lex = lexer.Lexer(sc)
try:
par = parser.Parser(lex)
interpreter = parser.Interpreter(par)
interpreter.clear()
interpreter.to_python()
except Exception as reason:
pireal = Pireal.get_service("pireal")
pireal.show_error_message(self.parse_error(reason.__str__()))
return
relations.update(table_widget.relations)
for relation_name, expression in list(interpreter.SCOPE.items()):
if relation_name in relations:
QMessageBox.critical(self,
self.tr("Query Error"),
self.tr("<b>{}</b> is a duplicate "
"relation name.<br><br> "
"Please choose a unique name "
"and re-execute the "
"queries.".format(
relation_name)))
del interpreter.SCOPE[relation_name]
return
try:
new_relation = eval(expression, {}, relations)
except Exception as reason:
pireal = Pireal.get_service("pireal")
pireal.show_error_message(self.parse_error(reason.__str__()),
syntax_error=False)
return
relations[relation_name] = new_relation
self.__add_table(new_relation, relation_name)
示例4: execute_queries
def execute_queries(self):
# Editor instance
query_editor = Pireal.get_service("query-editor").editor
query = query_editor.toPlainText() # Text
# Parse query
expression = parser.convert_to_python(query)
table_widget = Pireal.get_service("db")
rel = eval(expression, table_widget.relations)
示例5: new_query
def new_query(self, filename=''):
query_widget = Pireal.get_service("query_widget")
self.addWidget(query_widget)
if not query_widget.isVisible():
query_widget.show()
pireal = Pireal.get_service("pireal")
pireal.enable_disable_query_actions()
query_widget.new_query(filename)
self.connect(query_widget,
SIGNAL("currentEditorSaved(QPlainTextEdit)"),
self.save_query)
示例6: add_table
def add_table(self, rela, rname):
central_widget = Pireal.get_service("central")
lateral_widget = Pireal.get_service("lateral_widget")
db = central_widget.get_active_db()
_view = db.create_table(rela, rname, editable=False)
table_widget = central_widget.get_active_db().table_widget
index = table_widget.stacked_result.addWidget(_view)
table_widget.stacked_result.setCurrentIndex(index)
lateral_widget.result_list.add_item(
rname, rela.cardinality(), rela.degree())
# lateral_widget.result_list.select_last()
table_widget._tabs.setCurrentIndex(1)
示例7: new_query
def new_query(self):
from src.gui.query_editor import query_widget
widget = query_widget.QueryWidget()
pireal = Pireal.get_service("pireal")
# Load the instance
Pireal.load_service("query-editor", widget)
# MdiArea
mdi = Pireal.get_service("mdi")
widget.setMinimumSize(mdi.width(), mdi.minimumSizeHint().height())
mdi.addSubWindow(widget)
# Enable querie's QAction
pireal.enable_disable_query_actions()
widget.show()
示例8: __init__
def __init__(self, parent=None):
super(Notification, self).__init__(parent)
box = QVBoxLayout(self)
box.setContentsMargins(50, 0, 0, 0)
self.notificator = QLabel("")
box.addWidget(self.notificator)
# Timer
self.timer = QTimer(self)
self.timer.timeout.connect(self.clear)
# Install service
Pireal.load_service("notification", self)
示例9: __init__
def __init__(self):
super(LateralWidget, self).__init__()
self._list_widget = QListWidget()
self.setWidget(self._list_widget)
Pireal.load_service("lateral", self)
self._list_widget.setContextMenuPolicy(Qt.CustomContextMenu)
self.connect(self._list_widget, SIGNAL("currentRowChanged(int)"),
self._change_item)
self.connect(self._list_widget,
SIGNAL("customContextMenuRequested(const QPoint)"),
self.__show_context_menu)
示例10: __init__
def __init__(self, orientation=Qt.Vertical):
super(Container, self).__init__(orientation)
self._data_bases = []
self.__filename = ""
vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
self.__created = False
# Stacked
self.stacked = QStackedWidget()
vbox.addWidget(self.stacked)
# Table
self.table_widget = table_widget.TableWidget()
Pireal.load_service("container", self)
示例11: create_data_base
def create_data_base(self):
mdi = Pireal.get_service("mdi")
db_name, ok = QInputDialog.getText(mdi, self.tr("New DB"),
self.tr("Name:"),
text=getpass.getuser())
if ok:
from src.gui import table_widget
db_widget = table_widget.MdiDB()
db_widget.setWindowTitle(db_name + '.pdb')
db_widget.setMinimumSize(mdi.width(), mdi.height() / 1.7)
mdi.addSubWindow(db_widget)
# Enable QAction's
pireal = Pireal.get_service("pireal")
pireal.enable_disable_db_actions()
db_widget.show()
示例12: clear_results
def clear_results(self):
central_widget = Pireal.get_service("central")
lateral_widget = Pireal.get_service("lateral_widget")
lateral_widget.result_list.clear_items()
table_widget = central_widget.get_active_db().table_widget
i = table_widget.stacked_result.count()
# i = self._stack_tables.count()
while i >= 0:
# widget = self._stack_tables.widget(i)
widget = table_widget.stacked_result.widget(i)
# self._stack_tables.removeWidget(widget)
table_widget.stacked_result.removeWidget(widget)
if widget is not None:
widget.deleteLater()
i -= 1
示例13: add_new_table
def add_new_table(self, rel, name):
import itertools
table = QTableWidget()
table.setRowCount(0)
table.setColumnCount(0)
data = itertools.chain([rel.fields], rel.content)
for row_data in data:
row = table.rowCount()
table.setColumnCount(len(row_data))
for col, text in enumerate(row_data):
item = QTableWidgetItem()
item.setText(text)
if row == 0:
table.setHorizontalHeaderItem(col, item)
else:
table.setItem(row - 1, col, item)
table.insertRow(row)
table.removeRow(table.rowCount() - 1)
self.stacked.addWidget(table)
self.stacked.setCurrentIndex(self.stacked.count() - 1)
lateral = Pireal.get_service("lateral")
lateral.add_item_list([name])
示例14: add_data_base
def add_data_base(self, data):
lateral = Pireal.get_service("lateral")
rel = None
for part in data.split('@'):
for e, line in enumerate(part.splitlines()):
if e == 0:
name = line.split(':')[0]
rel = relation.Relation()
rel.fields = line.split(':')[-1].split(',')
else:
rel.insert(line.split(','))
if rel is not None:
table = Table()
table.setRowCount(1)
table.setColumnCount(0)
self.relations[name] = rel
for _tuple in rel.content:
row = table.rowCount()
table.setColumnCount(len(rel.fields))
for column, text in enumerate(_tuple):
item = Item()
item.setText(text)
table.setItem(row - 1, column, item)
table.insertRow(row)
table.setHorizontalHeaderLabels(rel.fields)
self.stacked.addWidget(table)
table.removeRow(table.rowCount() - 1)
lateral.add_item_list([name])
示例15: _check_count
def _check_count(self):
""" Hide dock if count = 0 """
if self.tab.count() == 0:
pireal = Pireal.get_service("pireal")
pireal.enable_disable_query_actions(False)
self.hide()