Python-Kivyのボタンの操作
Kivyは、Pythonのプラットフォームに依存しないGUIツールです。 Android、IOS、Linux、Windowsなどで実行できるため、Kivyは、コードを1回記述して、さまざまなプラットフォームで実行する機能を提供します。基本的にAndroidアプリケーションの開発に使用されますが、デスクトップアプリケーションで使用できないという意味ではありません。
ボタンは、ボタンが押されたとき(またはクリック/タッチ後に離されたとき)にトリガーされるアクションが関連付けられたラベルです。ボタンの後ろに関数を追加して、ボタンのスタイルを設定できます。
例
# import kivy module
import kivy
# this restrict the kivy version below this kivy version you cannot
# use the app or software
kivy.require("1.9.1")
# base Class of your App inherits from the App class.
# app:always refers to the instance of your application
from kivy.app import App
# creates the button in kivy if not imported shows the error
from kivy.uix.button import Button
# class in which we are creating the button
class ButtonApp(App):
def build(self):
# use a (r, g, b, a) tuple
btn = Button(text ="Push Me !",
font_size ="20sp",
background_color =(1, 1, 1, 1),
color =(1, 1, 1, 1),
size =(32, 32),
size_hint =(.2, .2),
pos =(300, 250))
# bind() use to bind the button to function callback
btn.bind(on_press = self.callback)
return btn
# callback function tells when button pressed
def callback(self, event):
print("button pressed")
print('Kivy!')
# creating the object root for ButtonApp() class
root = ButtonApp()
#run function runs the whole program. run() method which calls the #target function passed to the constructor.
root.run() -
Pythonで画像を操作しますか?
最も人気があり、画像処理用のPythonのデフォルトライブラリと見なされているものの1つは、Pillowです。 Pillowは、Python Image LibraryまたはPILの更新バージョンであり、さまざまなシンプルで高度な画像操作機能をサポートしています。これは、sciPyやMatplotlibなどの他のPythonライブラリでの単純な画像サポートの基礎でもあります。 枕の取り付け 始める前に、Pythonと枕が必要です。 Linuxの場合、Fedora、Debian / Ubuntu、ArchLinuxなどのLinuxの主要なフレーバーには、以前はPILが含まれていたパッケージにP
-
PythonでPDFファイルを操作しますか?
Pythonは、さまざまな要件に対応するための膨大なライブラリセットを提供するため、非常に用途の広い言語です。私たちは皆、Portable Document Format(PDF)ファイルに取り組んでいます。 Pythonは、PDFファイルを操作するためのさまざまな方法を提供します。ここでは、PyPDF2というPythonライブラリを使用してPDFファイルを操作します。 PyPDF2は、PDFファイルのページを分割、マージ、トリミング、および変換できる純粋なPythonPDFライブラリです。また、カスタムデータ、表示オプション、およびパスワードをPDFファイルに追加することもできます。 PD