Friday, April 16, 2021

Install Virtual Box on Fedora 34 via rpmfusion repository

****************************************************************

UPDATE as of 04/23/2021  Link below doesn't  provide kernel-devel install anymore. For myself the easiest way is to rebuild     kernel-5.11.15-300.fc34.src.rpm  and install locally all required rpms along with kernel-5.11.15 itself . Build on WD500 NVMe device reduce build-time in 4 times vs SATA SSD on the same box.

$ sudo dnf builddep kernel-5.11.15-300.fc34.src.rpm         

rpmbuild --rebuild kernel-5.11.15-300.fc34.src.rpm















To succeed with Virtual Box 6.1.20 installation per https://kifarunix.com/install-virtualbox-6-1-on-fedora/    you still  would have to rebuild kernel-5.11.15-300.fc34.src.rpm, otherwise instruction from link above :-

$ sudo dnf -y install VirtualBox-6.1-6.1.20_143896_fedora33-1.x86_64.rpm

will report : - This system is currently not set up to build kernel modules. Please install the Linux kernel "header" files matching the current kernel for adding new hardware support to the system.  The distribution packages containing the headers are probably:

    kernel-devel kernel-devel-5.11.15-300.fc34.x86_64

****************************************************************

 The most recent update to F34 installs kernel 5.11.14 and  kernel-devel-5.11.14-300.fc34.x86_64 at a time . What makes possible to install Virtual Box 6.1.18 via rpmfusion repository .

To force this update see https://bodhi.fedoraproject.org/updates/FEDORA-2021-d56567bdab

$ sudo dnf upgrade --enablerepo=updates-testing \
                    --advisory=FEDORA-2021-d56567bdab
Last metadata expiration check: 0:00:40 ago on Sat 17 Apr 2021 03:09:01 PM MSK.
Dependencies resolved.
===========================================================================================
 Package                   Arch        Version                  Repository            Size 
===========================================================================================
Installing:                                                                                
 kernel                    x86_64      5.11.14-300.fc34         updates-testing      151 k 
 kernel-core               x86_64      5.11.14-300.fc34         updates-testing       34 M 
 kernel-devel              x86_64      5.11.14-300.fc34         updates-testing       14 M 
 kernel-modules            x86_64      5.11.14-300.fc34         updates-testing       31 M 
 kernel-modules-extra      x86_64      5.11.14-300.fc34         updates-testing      2.1 M 
Upgrading:                                                                                 
 kernel-headers            x86_64      5.11.14-300.fc34         updates-testing      1.2 M 
Removing:                                                                                  
 kernel                    x86_64      5.11.11-300.fc34         @fedora                0  
 kernel-core               x86_64      5.11.11-300.fc34         @fedora               74 M
 kernel-devel              x86_64      5.11.11-300.fc34         @fedora               56 M
 kernel-modules            x86_64      5.11.11-300.fc34         @fedora               30 M
 kernel-modules-extra      x86_64      5.11.11-300.fc34         @fedora              1.9 M

Transaction Summary
===========================================================================================
Install  5 Packages
Upgrade  1 Package
Remove   5 Packages

Total download size: 82 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): kernel-5.11.14-300.fc34.x86_64.rpm                  222 kB/s | 151 kB     00:00    
(2/6): kernel-devel-5.11.14-300.fc34.x86_64.rpm            1.3 MB/s |  14 MB     00:10    
(3/6): kernel-modules-extra-5.11.14-300.fc34.x86_64.rpm    1.2 MB/s | 2.1 MB     00:01    
(4/6): kernel-headers-5.11.14-300.fc34.x86_64.rpm          858 kB/s | 1.2 MB     00:01    
(5/6): kernel-core-5.11.14-300.fc34.x86_64.rpm             1.6 MB/s |  34 MB     00:20    
(6/6): kernel-modules-5.11.14-300.fc34.x86_64.rpm          1.5 MB/s |  31 MB     00:20    
-------------------------------------------------------------------------------------------
Total                                                      3.8 MB/s |  82 MB     00:21     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                   1/1 
  Installing       : kernel-core-5.11.14-300.fc34.x86_64                              1/12 
  Running scriptlet: kernel-core-5.11.14-300.fc34.x86_64                              1/12 
  Installing       : kernel-modules-5.11.14-300.fc34.x86_64                           2/12 
  Running scriptlet: kernel-modules-5.11.14-300.fc34.x86_64                           2/12 
  Installing       : kernel-5.11.14-300.fc34.x86_64                                   3/12 
  Installing       : kernel-modules-extra-5.11.14-300.fc34.x86_64                     4/12 
  Running scriptlet: kernel-modules-extra-5.11.14-300.fc34.x86_64                     4/12 
  Upgrading        : kernel-headers-5.11.14-300.fc34.x86_64                           5/12 
  Installing       : kernel-devel-5.11.14-300.fc34.x86_64                             6/12 
  Running scriptlet: kernel-devel-5.11.14-300.fc34.x86_64                             6/12 
  Erasing          : kernel-modules-extra-5.11.11-300.fc34.x86_64                     7/12 
  Running scriptlet: kernel-modules-extra-5.11.11-300.fc34.x86_64                     7/12 
  Erasing          : kernel-5.11.11-300.fc34.x86_64                                   8/12 
  Running scriptlet: kernel-5.11.11-300.fc34.x86_64                                   8/12 
  Erasing          : kernel-modules-5.11.11-300.fc34.x86_64                           9/12 
  Running scriptlet: kernel-modules-5.11.11-300.fc34.x86_64                           9/12 
  Running scriptlet: kernel-core-5.11.11-300.fc34.x86_64                             10/12 
  Erasing          : kernel-core-5.11.11-300.fc34.x86_64                             10/12 
dkms: running auto installation service for kernel 5.11.14-300.fc34.x86_64
 Done. 
  Running scriptlet: kernel-headers-5.11.11-300.fc34.x86_64                          12/12 
  Verifying        : kernel-5.11.14-300.fc34.x86_64                                   1/12 
  Verifying        : kernel-core-5.11.14-300.fc34.x86_64                              2/12 
  Verifying        : kernel-devel-5.11.14-300.fc34.x86_64                             3/12 
  Verifying        : kernel-modules-5.11.14-300.fc34.x86_64                           4/12 
  Verifying        : kernel-modules-extra-5.11.14-300.fc34.x86_64                     5/12 
  Verifying        : kernel-headers-5.11.14-300.fc34.x86_64                           6/12 
  Verifying        : kernel-headers-5.11.11-300.fc34.x86_64                           7/12 
  Verifying        : kernel-5.11.11-300.fc34.x86_64                                   8/12 
  Verifying        : kernel-core-5.11.11-300.fc34.x86_64                              9/12 
  Verifying        : kernel-devel-5.11.11-300.fc34.x86_64                            10/12 
  Verifying        : kernel-modules-5.11.11-300.fc34.x86_64                          11/12 
  Verifying        : kernel-modules-extra-5.11.11-300.fc34.x86_64                    12/12 
Upgraded:
  kernel-headers-5.11.14-300.fc34.x86_64                                                   
Installed:
  kernel-5.11.14-300.fc34.x86_64                  kernel-core-5.11.14-300.fc34.x86_64      
  kernel-devel-5.11.14-300.fc34.x86_64            kernel-modules-5.11.14-300.fc34.x86_64   
  kernel-modules-extra-5.11.14-300.fc34.x86_64   
Removed:
  kernel-5.11.11-300.fc34.x86_64                  kernel-core-5.11.11-300.fc34.x86_64      
  kernel-devel-5.11.11-300.fc34.x86_64            kernel-modules-5.11.11-300.fc34.x86_64   
  kernel-modules-extra-5.11.11-300.fc34.x86_64   

Setup rpmfusion :-

$ sudo dnf install \ https://download1.rpmfusion.org/free/fedora/rpmfusion-
free-release-$(rpm -E %fedora).noarch.rpm 

$ sudo dnf \     install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

$ sudo dnf install VirtualBox kernel-devel-$(uname -r) akmod-VirtualBox

$ sudo akmods
$ sudo systemctl restart vboxdrv 

$ lsmod | grep -i vbox

vboxnetadp             28672  0
vboxnetflt             32768  1
vboxdrv               557056  3 vboxnetadp,vboxnetflt








Now deploy F34 Prerelease WKS via Virtual Box ( Linux Bridge VM's network setup )





















































Saturday, April 10, 2021

Setting up PyQt5 in PyCharm 2021.1 on AlmaLinux 8.3

In general,  procedure bellow follows guidelines from http://lxer.com/module/newswire/view/298983/index.html attempting to test AlmaLinux 8.3 rather then PyQT5 Framework.

PyQt5 is a comprehensive set of Python bindings for Qt v5. It is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android.  Following below is a brief description to enable PyCharm 2021.1 to execute python scripts been written with PyQT5 bindings involved on AlmaLinux 8.3.

First install packages :-

$ sudo dnf install qt5-qtbase-devel

$ sudo dnf install PyQt5 

$ sudo dnf install qt5-designer

Afterward install the most recent version of PyCharm on Linux.


















































































Now test setup via porting from GitHub SqliteBrowser been compiled via PyQT5 in PyCharm 2021.1 environment













































Friday, April 2, 2021

Setting up PyQt5 in PyCharm 2020.3.5 on Fedora 33 Server

*************************************************************

Update as of 04/11/2021. See also Setting up PyQt5 in PyCharm 2021.1 on AlmaLinux 8.3

*************************************************************

Following below is a brief description to enable PyCharm 2020.3.5 to execute python scripts been written with PyQT5 bindings involved.

PyQt5 is a comprehensive set of Python bindings for Qt v5. It is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android.

First install packages :-

$ sudo dnf install qt5-qtbase-devel

$ sudo dnf install PyQt5 

$ sudo dnf install qt5-designer

Afterward install the most recent version of PyCharm on Linux.

Start PyCharm via desktop link to shell executable

(KDE Desktop environment)

Per https://pythonpyqt.com/how-to-install-pyqt5-in-pycharm/

Step 1 Create a new project

Step 2 Set the default PyCharm parser.

Select File | Settings | Project: first | Project Interpreter, set Project Interpreter to The version of python you are using

Step 3 Adding third-party libraries. Stay in the Project Interpreter interface, click on the +, find and install pyqt5pyqt5-sippyqt5-tools. After successful installation, the interface should look like this.















Step 4 Configuring QtDesigner

Due to qt5-designer has been installed, configure it in PyCharm 

Then configure PyUIC tools

Arguments: -m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py

PyCharm select File | Settings | Tools | PyCharm. External Tools, click + New Tools



















SQLITE3 Database administration via PyQT5 Framework in PyCharm 3.5 Environment Database administration via PyQT5 Framework in PyCharm 3.5 EnvironmentNow test at run time  code from link mentioned above  https://realpython.com/python-pyqt-layout/

import sys
 2
 3from PyQt5.QtWidgets import (
 4    QApplication,
 5    QComboBox,
 6    QFormLayout,
 7    QLineEdit,
 8    QStackedLayout,
 9    QVBoxLayout,
10    QWidget,
11)
12
13class Window(QWidget):
14    def __init__(self):
15        super().__init__()
16        self.setWindowTitle("QStackedLayout Example")
17        # Create a top-level layout
18        layout = QVBoxLayout()
19        self.setLayout(layout)
20        # Create and connect the combo box to switch between pages
21        self.pageCombo = QComboBox()
22        self.pageCombo.addItems(["Page 1", "Page 2"])
23        self.pageCombo.activated.connect(self.switchPage)
24        # Create the stacked layout
25        self.stackedLayout = QStackedLayout()
26        # Create the first page
27        self.page1 = QWidget()
28        self.page1Layout = QFormLayout()
29        self.page1Layout.addRow("Name:", QLineEdit())
30        self.page1Layout.addRow("Address:", QLineEdit())
31        self.page1.setLayout(self.page1Layout)
32        self.stackedLayout.addWidget(self.page1)
33        # Create the second page
34        self.page2 = QWidget()
35        self.page2Layout = QFormLayout()
36        self.page2Layout.addRow("Job:", QLineEdit())
37        self.page2Layout.addRow("Department:", QLineEdit())
38        self.page2.setLayout(self.page2Layout)
39        self.stackedLayout.addWidget(self.page2)
40        # Add the combo box and the stacked layout to the top-level layout
41        layout.addWidget(self.pageCombo)
42        layout.addLayout(self.stackedLayout)
43
44    def switchPage(self):
45        self.stackedLayout.setCurrentIndex(self.pageCombo.currentIndex())
46
47if __name__ == "__main__":
48    app = QApplication(sys.argv)
49    window = Window()
50    window.show()
51    sys.exit(app.exec_())





























Another sample


















OLD PROGRAMMER'S CODE @ YANDEX.ZEN

#!/usr/bin/python3
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QWidget, QFileDialog
from PyQt5.QtWidgets import QLabel
from PyQt5.QtCore import Qt, QSize
import sys
class win(QWidget):
   def __init__(self,x, y, dx, dy):
       super().__init__()
       self.setGeometry(x, y, dx, dy)
       self.setWindowTitle('Picture in window')
       fn = QFileDialog.getOpenFileName(self, \
         'Select a picture', '', '*.jpg *.png *.gif *.bmp')
       self.pix = QPixmap(fn[0])
       self.im = QLabel(self)
       self.im.move(0, 0)
       self.pix = self.pix.scaled(QSize(dx, dy), \
         Qt.KeepAspectRatio, Qt.SmoothTransformation);
       self.im.setPixmap(self.pix)
       self.setFixedSize(self.pix.width(), self.pix.height())
app = QApplication(sys.argv)
ex = win(50, 50, 800, 700)
ex.show()
sys.exit(app.exec())



































======================================================

SQLITE3 Database administration via PyQT5 Framework in PyCharm 3.5 Environment

======================================================

making minor changes to original code on Fedora 33 Server having previously enabled PyQT5 support by PyCharm

[boris@fedora33server PYQT]$ cat sqlcreate.py
import sys
from PyQt5.QtSql import QSqlDatabase, QSqlQuery
con = QSqlDatabase.addDatabase("QSQLITE")
con.setDatabaseName("contacts.sqlite")

if not con.open():
    print("Database Error: %s" % con.lastError().databaseText())
    sys.exit(1)

# Create a query and execute it right away using .exec()
createTableQuery = QSqlQuery()
createTableQuery.exec(
    """
    CREATE TABLE contacts (
        id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL,
        name VARCHAR(40) NOT NULL,
        job VARCHAR(50),
        email VARCHAR(40) NOT NULL
    )
    """
)
print(con.tables())

Loading data into created table

[boris@fedora33server PYQT]$ cat sql02.py
from PyQt5.QtSql import QSqlQuery, QSqlDatabase

con = QSqlDatabase.addDatabase("QSQLITE")
con.setDatabaseName("contacts.sqlite")
con.open()
insertDataQuery = QSqlQuery()
insertDataQuery.prepare(
    """
    INSERT INTO contacts (
        name,
        job,
        email
    )
    VALUES (?, ?, ?)
    """
)
data = [
    ("Joe", "Senior Web Developer", "joe@example.com"),
    ("Lara", "Project Manager", "lara@example.com"),
    ("David", "Data Analyst", "david@example.com"),
    ("Jane", "Senior Python Developer", "jane@example.com"),
]
# Use .addBindValue() to insert data
for name, job, email in data:
    insertDataQuery.addBindValue(name)
    insertDataQuery.addBindValue(job)
    insertDataQuery.addBindValue(email)
    insertDataQuery.exec()

[boris@fedora33server PYQT]$ cat sqliteditor.py
import sys

from PyQt5.QtCore import Qt
from PyQt5.QtSql import QSqlDatabase, QSqlTableModel
from PyQt5.QtWidgets import (
    QApplication,
    QMainWindow,
    QMessageBox,
    QTableView,
)
class Contacts(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle("QTableView Example")
        self.resize(415, 200)
        # Set up the model
        self.model = QSqlTableModel(self)
        self.model.setTable("contacts")
        self.model.setEditStrategy(QSqlTableModel.OnFieldChange)
        self.model.setHeaderData(0, Qt.Horizontal, "ID")
        self.model.setHeaderData(1, Qt.Horizontal, "Name")
        self.model.setHeaderData(2, Qt.Horizontal, "Job")
        self.model.setHeaderData(3, Qt.Horizontal, "Email")
        self.model.select()
        # Set up the view
        self.view = QTableView()
        self.view.setModel(self.model)
        self.view.resizeColumnsToContents()
        self.setCentralWidget(self.view)

def createConnection():
    con = QSqlDatabase.addDatabase("QSQLITE")
    con.setDatabaseName("contacts.sqlite")
    if not con.open():
        QMessageBox.critical(
            None,
            "QTableView Example - Error!",
            "Database Error: %s" % con.lastError().databaseText(),
        )
        return False
    return True

app = QApplication(sys.argv)
if not createConnection():
    sys.exit(1)
win = Contacts()
win.show()
sys.exit(app.exec_())