ari webhu webhu Ivo vari pano kuti vagare, uye vari kushandiswa zvakanyanya uye zvakanyanya. Imwe nguva yapfuura, masevhisi akaita seTwitter aive akasiyana zvakanyanya, ikozvino ave rudzi rwemafoni ekushandisa anojairana nechidzitiro chemudziyo watinopinda nawo. Asi iyo yakadzikama yeaya maapps ndeyekuti anomhanya mubrowser, uye kune mashoma mabhurawuza mazuva ano asina kunyatso shandisa zviwanikwa. Panogona kunge paine, asi ko kana paine chimwe chinhu chakareruka, kunyange kupfuura izvo Linux mint inopa?
Chokwadi, isu tinogona kushandisa Chromium-based browser togadzira nzira yekudimbudzira kana kuisa iyo app uye zvatichava nazvo zvichange zvakaita setabhu rakasununguka rinoshandisa zviwanikwa zvishoma pane yakazara browser. Ichokwadi, izvi zvinokwanisika, asi, zvichienderana newebhu iyo inofanirwa kutakura, uremu hunogona kusiyana, uye, mumaonero angu, haisi zvachose yakaderera. Qt Inopa widget iyo ndeyekuratidza zvemukati zvewebhu, uye chakavanzika pano kugadzira chishandiso chiri nyore chinoremedza iyo webhu uchishandisa Python. Zvinogoneka nemimwe mitauro, asi Python ndiyo inodhura zvakanyanya.
Maitiro ekugadzira webhu app nePython
Kuti uenderere mberi, unofanirwa kuve nemapakeji akati wandei akaiswa. Ehe, kana isu tichida kumhanya iyo webhu app nayo Python, isu tichada Python; shanduro yekugovera kwedu inofanira kuva yechokwadi. Izvo zvinodiwawo kuve nePyQt5 webengine package yakaiswa (iyo PyQt6 imwe inoshandawo, asi kodhi ichasiyana), uye zita rayo chairo rinoenderana ne distro yatiri kushandisa. PaArch Linux uye zvinobva kunowanikwa se python-pyqt5-webengine, uye paUbuntu nezvinobuda kazhinji iri python3-pyqt5.qtwebengine. Kana aya mapakeji aiswa, isu tinenge tine zvese zvekugadzira edu ewebhu maapplication. Matanho ekutevera angave aya:
- Isu tinogadzira faira nyowani. Zita racho harina basa, asi zvakakosha kuti rive rinotsanangura kuti tizive kuti chii. Kuwedzerwa kunofanirwa kuve .py kana tichizoshandisa Python.
- Isu tinoisa iyi kodhi, kutsanangura gare gare:
#. , 3, 5) MainWindow.setMinimumSize(5, 100) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QWidgetEngine. .QWebEngineView(self.centralwidget) self.verticalLayout.addWidget(self.webEngineView) self.verticalLayout.setContentsMargins(100, 1200, 760, 400) self.webEngineView.setUrl(QtCore.QUrl("https://pluto.tv" )) self.webEngineView.setObjectName("webEngineView") MainWindow.setCentralWidget(self.centralwidget) kana __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) MainWindow = Qt uWindow = QtiWindow () ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_())
Kuve Python, iwe unofanirwa kuchenjerera neiyo indentation, ndiko kuti, nenzvimbo kubva kuruboshwe kumucheto kusvika kune yekutanga tsamba. Kana zvese zviri zvekirasi imwechete kana basa zvisina kunaka uye pahurefu hwakafanana, Python inoona kuti ndeye kumwewo uye haishande. Asi ngatiende nhanho nhanho.
- Ngatitii zvatinoda kugadzira iyo Pluto TV app, uye kuti faira redu rinonzi pluto.py. Isu chechipiri tinya pluto.py, enda kune zvaunofarira uye womaka iyo seinogoneka. Isu tinogona zvakare kuvhura terminal uye mhando:
chmod +x pluto.py
- Zvino isu tinofanirwa kukwanisa kuivhura nekudzvanya kaviri, asi zvakakosha kuti tiite kutanga kubva kune terminal. Isu tinovhura imwe uye tonyora python pluto.py. Pane kumwe kugoverwa kungave kuri madikanwa kuchinja "python" kuita "python3".
- Kana tikaona kuti inovhura, isu tatova newebhu app yedu yakagadzirwa. Tinogona kugadzira .desktop faira kuti ibude mumaapplications menyu kana chero, asi iyo application inenge yatogadzirwa. Iwo mameseji ekukanganisa anoonekwa mune terminal anogona kufuratirwa kana iyo app ikashanda.
kutsanangura kodhi
Kubva pane kodhi iri pamusoro, mutsara wekutanga ndeye "shebang" inoratidza chii chichavhura faira. Yakandishandira neiyo mune chero Linux distro, asi inogona kusiyana mune imwe. Zvazvinotaura kuvhura nePython. Zvadaro kirasi inogadzirwa, chinhu chikuru chehwindo. Mukati tine basa richaratidza mushandisi interface. Iyo .setGeometry() uye .setMinimumSize() nzira ndedzekuti ichange iine zviyero zvakadii kana yakavhurwa uye kuti hudiki hwakadii. Mu.setGeometry() unofanirawo kuratidza nhamba mbiri (100,100); mamwe ndiwo makuriro. Wobva wauya mitsara inogadzira iyo widget kuti utarise peji rewebhu uye chinhu chekupedzisira (kana __name__…) ndicho chinotangisa application. Webhu app ichava iyo pakati pemakotesheni akatenderedza nzira yeQUrl.
Ongorora: maapplication ewebhu anoratidzwa mune yakakosha kuona
Chero ani anofunga izvi zviri nani pane, ini handizive, kuisa Photopea muChromium-based browser, zvikanganwe. Ehe mawebhusaiti aya anogona kuvandudzwa kuti aite sezvavanoita mubrowser, asi kwete nematanho akareruka anosanganisirwa mumusoro. Izvi zvichashanda kuve nemaapplication akaita seYouTube, Pluto TV, Twitter... asi haugone kurodha mafaera, haichengetedze mapassword kana kuti inogona kuisa edzedzero.
Chinhu chakanakisa pane izvi ndechekuti, chaizvo nekuti ingori yekutanga uye ine mashoma muoni, iyo webhu application ichapedza zviwanikwa zvishoma kupfuura Chromium imwe. Kana iri Photopea, sezvo isina majeti anobvunza kupi kuchengetedza magwaro, kana chero basa rinoita kuti rinyorwe kune hard drive, iyo mifananidzo haigone kuchengetwa. Ndakaedza uye vanogona kusimudzwa nekukwevera mukati mehwindo, asi kwete kudzikiswa. Muchiitiko ichi chaicho, chii chingaitwa ndechokugovera chinyorwa, kukopa chibatanidzo chaanotipa uye kuzarura kune imwe nzvimbo, asi chibatanidzo chinovhura Photopea ... Ndakatozvitaura, zvinokosha.
Asi zvakakosha hazvina maturo, uye kana zvichigona kubatsira mumwe munhu, ndichafara.