Follow the ghost Brother to learn PyQtPart.2, ghost Brother pyqtpart.2

Source: Internet
Author: User
Tags emit

Follow the ghost Brother to learn PyQtPart.2, ghost Brother pyqtpart.2

<Span style = "font-family: Arial, Helvetica, sans-serif;"> 0x1: </span> <span style = "font-family:; "> brief description </span>

After the simple layout in the first article, can we consider whether we can put a button to execute relevant actions? The answer is yes. After testing, we have simply sorted out the Click Event Response of a button to execute the decompilation action. Here we will record the learning process.


0x2: thinking process

We want to perform the decompilation action. First, we need to prepare the relevant things required for the decompilation. Therefore, we download apktool. jar to execute relevant actions. Here we use a friend-compiled version 1.5 apktool. The URL is:

Http://bbs.chinaunix.net/thread-4096302-1-1.html

You can use the apktool. jar command. We can use Python to execute the cmd command, so this can be implemented.

After processing this method, you need to associate it with the button click event. Then we will implement this separately.


0x3: Implementation of The Decompilation Method
Import OS ##### set the apk path. Here we first use a fixed path #### apk_path = OS. getcwd () + "\ aa.apk" def apkD (apk_path): ### print the path to see if it is correct #### print (apk_path) ### apktool command ##### apktodd = 'java-jar apktool. jar d' + apk_path ### check whether the command is correct. If yes, write an error ### print (apktop) ### call the OS system command to execute cmd-related commands ### OS. system (apktodd) apkD (apk_path)


The Code has clearly written detailed comments. Here we can take a look at it to prove that our method is effective:









Now we can implement this function, that is, using apktool. jar commands can be implemented through the command line. You only need to configure the java environment variables. Next, we will compile a button to implement simple mouse click events.

 

0x4: Implementation of mouse click events

Import sysimport osfrom PyQt4 import QtGuifrom PyQt4 import QtCore ### apk location. For the current class, put it in the directory where the current file is located ### apk_path = OS. getcwd () + "\ aa.apk" ################################ self define the window class ##################################### class MyWindow (QtGui. QWidget ): '''custom window class''' ################################ Structure, destructor #################################### def __ init _ (self, parent = None): '''constructor ''' # Call the parent class constructor super (MyWindow, self ). _ init _ (parent) # set fixed window size self. setFixedSize (QtCore. QSize (800,600) # create the main control bodyWidget = QtGui. QWidget (self) # create the main layout mainLayout = QtGui. QVBoxLayout (bodyWidget) # create a custom button = MyButton (self) # Set the text content button. setText ("Apk_Decode") # Add the mainLayout control. addWidget (button) # Set the button and click the connection slot function button. clicked. connect (self. onClick) ################################ command ######## ################################ def OnClick (self): ''' response click ''' QtGui. QMessageBox. about (self, "apk_d", "apk is decoding ") ################################ event ####### ################################# def mousePressEvent (self, event): ''' click the event ''' # determines whether the event is left-clicked if event. button () = QtCore. qt. leftButton: # Set the window background color self. setStyleSheet ('''''') ################################## Custom button classes ## ################################## class MyButton (QtGui. QToolButton ): '''custom button class '''############################## constructor #################################### def _ init _ (self, parent = None): '''constructor ''' # Calls the parent class constructor super (MyButton, self ). _ init _ (parent) # Set the button size self. setFixedSize (QtCore. QSize (800,120) # Set the button background color self. setStyleSheet ('''background-color: red ;''') ################################ event ####### ################################## def mousePressEvent (self, event): ''' click the event ''' # determines whether the event is left-clicked if event. button () = QtCore. qt. leftButton: # launch click signal self. clicked. emit (True) # pass to the parent window to respond to the mouse and press the event self. parent (). mousePressEvent (event) ################################## main function #### ####################################### if _ _ name _ = "_ main __": '''main function''' # declare the variable app = QtGui. QApplication (sys. argv) # create window = MyWindow () # Set window display window. show () # Application Event loop sys.exit(app.exe c _())




The Code has a detailed comment. Here is the effect:







Click apk_decode. A dialog box is displayed, indicating that the decompilation is in progress. This indicates that the Click Event of the button has been written. Next, add the decompilation method, and put it in the button click event.

 

0x5: integrate two Codes

 

The Code is as follows:



Import sysimport osfrom PyQt4 import QtGuifrom PyQt4 import QtCore ### apk location. For the current class, put it in the directory where the current file is located ### apk_path = OS. getcwd () + "\ aa.apk" ################################ self define the window class ##################################### class MyWindow (QtGui. QWidget ): '''custom window class''' ################################ Structure, destructor #################################### def __ init _ (self, parent = None): '''constructor ''' # Call the parent class constructor super (MyWindow, self ). _ init _ (parent) # set fixed window size self. setFixedSize (QtCore. QSize (800,600) # create the main control bodyWidget = QtGui. QWidget (self) # create the main layout mainLayout = QtGui. QVBoxLayout (bodyWidget) # create a custom button = MyButton (self) # Set the text content button. setText ("Apk_Decode") # Add the mainLayout control. addWidget (button) # Set the button and click the connection slot function button. clicked. connect (self. onClick) ################################ command ######## ################################ def OnClick (self): ''' response click ''' QtGui. QMessageBox. about (self, "apk_d", "apk is decoding ") ############################## decompilation method ####### ################################# def apk_decode (self, path): print (path) apktodd = 'java-jar apktool. jar d' + path print (apktodd) OS. system (apktodd) ################################ event ####### ################################# def mousePressEvent (self, event): ''' click the event ''' # determines whether the event is left-clicked if event. button () = QtCore. qt. leftButton: # Set the window background color self. setStyleSheet (''') self.apk _ decode (apk_path) ################################## Custom button classes ## ################################## class MyButton (QtGui. QToolButton ): '''custom button class '''############################## constructor #################################### def _ init _ (self, parent = None): '''constructor ''' # Calls the parent class constructor super (MyButton, self ). _ init _ (parent) # Set the button size self. setFixedSize (QtCore. QSize (800,120) # Set the button background color self. setStyleSheet ('''background-color: red ;''') ################################ event ####### ################################## def mousePressEvent (self, event): ''' click the event ''' # determines whether the event is left-clicked if event. button () = QtCore. qt. leftButton: # launch click signal self. clicked. emit (True) # pass to the parent window to respond to the mouse and press the event self. parent (). mousePressEvent (event) ################################## main function #### ####################################### if _ _ name _ = "_ main __": '''main function''' # declare the variable app = QtGui. QApplication (sys. argv) # create window = MyWindow () # Set window display window. show () # Application Event loop sys.exit(app.exe c _())











We can see that we have successfully implemented the decompilation function by clicking the button.

0x6: Summary

We can implement the decompilation of buttons in a simple way. After all, there is no waste of time to prove that we can build a decompilation tool. In normal operations, we certainly won't write the apk path in the code. A common method is to add a window for selecting the apk path and then select the apk to determine the path of the apk. In the next article, we will explore how to implement this function.

On the second day of the Mid-Autumn Festival, I spent some time exploring in the afternoon...

Wish you a pleasant Mid-Autumn Festival ~~~

The above code is complete, so this article will not be uploaded to the online storage. You can directly copy the code and test it. Please feel free to contact us for help ~~~

 

Cracking group:, iegg

Love cracking, love ghost Brother: 377724636




Who played Bobo, sister of cool 2?

Li sibei
Baike.baidu.com/view/1561796.html? Wtp = tt

Who played the ghost Brother In Qisheng 2?

Hello!

It was played by Jiang haowen.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.