Home > other >  Cython a very simple but very tricky problems
Cython a very simple but very tricky problems

Time:11-24

This piece of code in cython compile time error:
 
# - * - coding: utf-8 - * -

# Form implementation generated from reading the UI file 'test_cython. UI'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
The import sys, OS
Sys. Path. Append ('../')
The from PyQt5. QtWidgets import *
The from PyQt5. QtWidgets import QPushButton
The from PyQt5. QtWidgets import QApplication
The from PyQt5. QtCore import QRect, QCoreApplication, QMetaObject
The from test_cython. Test_cython3 import *

The class Ui_MainWindow (QMainWindow) :
Def setupUi (self, the MainWindow) :
MainWindow. SetObjectName (" MainWindow ")
MainWindow. Resize (800, 600)
Self. Centralwidget=QWidget (MainWindow)
Self. Centralwidget. SetObjectName (" centralwidget ")
Self. PushButton=QPushButton (self. Centralwidget)
The self. The pushButton. SetGeometry (QRect (350, 210, 75, 23))
The self. The pushButton. SetObjectName (" pushButton ")
MainWindow. SetCentralWidget (self. Centralwidget)
The self. The menubar=QMenuBar (MainWindow)
The self. The menubar. SetGeometry (QRect (0, 0, 800, 23))
The self. The menubar. SetObjectName (" menubar ")
MainWindow. SetMenuBar (self. Menubar)
The self. The statusbar=QStatusBar (MainWindow)
The self. The statusbar. SetObjectName (" statusbar ")
MainWindow. SetStatusBar (self. The statusbar)

Self. RetranslateUi (MainWindow)
QMetaObject. ConnectSlotsByName (MainWindow)
The self. The pushButton. SetText (' test ')
Def TMP () :
The eval (' QDialog (). The exec () ')
The self. The pushButton. Clicked. Connect (TMP)

Def retranslateUi (self, the MainWindow) :
_translate=QCoreApplication. Translate
MainWindow. SetWindowTitle (_translate (" MainWindow ", "MainWindow"))
The self. The pushButton. SetText (_translate (" MainWindow ", "pushButton"))


App=QApplication (sys. Argv)
W=Ui_MainWindow ()
Baron etupUi (w)
Baron how ()

Sys. Exit (app. Exec_ ())



Error:


Then I found that as long as the code inside a ". The exec "cython cannot be compiled through, it's really a god,
The exec () to the show () compiled through, to eval (' QDialog (), exec () ') compilation can also pass,,

So in the exec cython there is a special string? Why there is no way to compile??
Great god give advice or comments, please ~!!

CodePudding user response:

The exec's built-in functions: https://docs.python.org/3/library/functions.html#exec

CodePudding user response:

Tick, tick,

CodePudding user response:

How to mark?

CodePudding user response:

Reference
then I found that as long as the code inside a ". The exec "cython cannot be compiled through, it's really a god,

According to the current check some information + experience judgment: you're unable to compile, always have a specific reason, so it's not god is not god, the key to see if you know what went wrong,

Reference
. The exec () into the show () compiled through

Specific code is?

Reference
to eval (' QDialog (), exec () ') compilation can also pass,,

See your existing code is:
 eval (' QDialog (), exec () ') 

Which means you can compile by you say?

For your problem, involve the QT, I am not very familiar with,

But can help you to clear some relevant knowledge:
1. The eval
Is the Python built-in function
Typical usage is:
  python
Python 3.6.5 (default, 29 Nov 2019, 11:38:35)
[GCC 2 Compatible Apple LLVM 10.0.1 (clang - 1001.0.46.4)] on Darwin
Type "help", "copyright", "credits" or "license" for more information.
> Print (eval)

> '3 + 4'
'3 + 4'
> Eval (' 3 + 4)
7
>

That is:
Ordinary string in python, just ordinary string
Plus the eval, forced to help you convert python code and then help you perform

2. You said the excel in QT and show
To help you search some information
The QDialog Class | Qt Widgets 5.15.0
Reference
The most common way to display a modal dialog is to call its exec () function. When The user closes The dialog, The exec () will dojo.provide a useful return value. To close The dialog and return The appropriate value, you must connect a default button, anyone with an OK button to The accept () slot and a Cancel button to The reject () slot. Alternatively, you can call The done () slot with Accepted or Rejected.

An alternative is to call setModal(true) or setWindowModality(), then show(). Unlike exec(), show() returns control to the caller immediately. Calling setModal(true) is especially useful for progress dialogs, where the user must have the ability to interact with the dialog, e.g. to cancel a long running operation. If you use show() and setModal(true) together to perform a long operation, you must call QCoreApplication::processEvents() periodically during processing to enable the user to interact with the dialog. (See QProgressDialog.)


- & gt; Overall:
Eval and use different show is
How to use specific
After your study, and then make a decision, and find a suitable for your case writing,

In addition to help you search the
QDialog python
Python QT window shows
Find some information may be your reference
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related