Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installing GObject module fails #2469

Open
Axel-Erfurt opened this issue Nov 13, 2023 · 2 comments
Open

installing GObject module fails #2469

Axel-Erfurt opened this issue Nov 13, 2023 · 2 comments

Comments

@Axel-Erfurt
Copy link

What were you trying to do?

installing GObject

What steps did you take to trigger the issue?

added GObject to Third Party Packages

What did you expect to happen?

installing GObject

What actually happened?

Error: error:
[Errno 2] No such file or directory: 'clang'

Operating System Version

LMDE6 (Debian 12)

Mu Version

1.2.0 Appimage

Other Info

Collecting pygobject
Using cached PyGObject-3.46.0.tar.gz (723 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [41 lines of output]
      Collecting setuptools
        Using cached setuptools-68.2.2-py3-none-any.whl.metadata (6.3 kB)
      Collecting wheel
        Using cached wheel-0.41.3-py3-none-any.whl.metadata (2.2 kB)
      Collecting pycairo
        Using cached pycairo-1.25.1.tar.gz (347 kB)
        Installing build dependencies: started
        Installing build dependencies: finished with status 'done'
        Getting requirements to build wheel: started
        Getting requirements to build wheel: finished with status 'done'
        Installing backend dependencies: started
        Installing backend dependencies: finished with status 'done'
        Preparing metadata (pyproject.toml): started
        Preparing metadata (pyproject.toml): finished with status 'done'
      Using cached setuptools-68.2.2-py3-none-any.whl (807 kB)
      Using cached wheel-0.41.3-py3-none-any.whl (65 kB)
      Building wheels for collected packages: pycairo
        Building wheel for pycairo (pyproject.toml): started
        Building wheel for pycairo (pyproject.toml): finished with status 'error'
        error: subprocess-exited-with-error
      
        × Building wheel for pycairo (pyproject.toml) did not run successfully.
        │ exit code: 1
        ╰─> [11 lines of output]
            running bdist_wheel
            running build
            running build_py
            creating build
            creating build/lib.linux-x86_64-cpython-38
            creating build/lib.linux-x86_64-cpython-38/cairo
            copying cairo/__init__.py -> build/lib.linux-x86_64-cpython-38/cairo
            copying cairo/__init__.pyi -> build/lib.linux-x86_64-cpython-38/cairo
            copying cairo/py.typed -> build/lib.linux-x86_64-cpython-38/cairo
            running build_ext
            error: [Errno 2] No such file or directory: 'clang'
            [end of output]
      
        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for pycairo
      Failed to build pycairo
      ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

FINISHED

Editor Log

2023-11-13 22:31:47,551 - root:283(run) INFO: 

-----------------

Starting Mu 1.2.0
2023-11-13 22:31:47,552 - root:284(run) INFO: uname_result(system='Linux', node='chieftech', release='6.1.0-13-amd64', version='#1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29)', machine='x86_64', processor='')
2023-11-13 22:31:47,553 - root:285(run) INFO: Platform: Linux-6.1.0-13-amd64-x86_64-with-glibc2.2.5
2023-11-13 22:31:47,553 - root:286(run) INFO: Python path: ['/tmp/.mount_Mu_EdiQUkMJR/usr/lib/python38.zip', '/tmp/.mount_Mu_EdiQUkMJR/usr/lib/python3.8', '/tmp/.mount_Mu_EdiQUkMJR/usr/lib/python3.8/lib-dynload', '/tmp/.mount_Mu_EdiQUkMJR/usr/lib/python3.8/site-packages']
2023-11-13 22:31:47,553 - root:287(run) INFO: Language code: de_DE
2023-11-13 22:31:47,554 - mu.settings:220(load) WARNING: No settings file found at /home/brian/.local/share/mu/settings.json; skipping
2023-11-13 22:31:47,819 - mu.virtual_environment:619(ensure_and_create) INFO: Added log handler.
2023-11-13 22:31:47,819 - mu.virtual_environment:630(ensure_and_create) DEBUG: Checking virtual environment; attempt #1.
2023-11-13 22:31:47,819 - mu.virtual_environment:719(ensure_path) INFO: Virtual Environment found at: /home/brian/.local/share/mu/mu_venv-38-20231112-194901
2023-11-13 22:31:47,820 - mu.virtual_environment:740(ensure_interpreter) INFO: No interpreter found at: /home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/python
2023-11-13 22:31:47,820 - mu.virtual_environment:750(ensure_interpreter) INFO: Symlinked /home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/python to AppImage's /tmp/.mount_Mu_EdiQUkMJR/usr/bin/python3.8
2023-11-13 22:31:47,820 - mu.virtual_environment:463(run_subprocess) INFO: Running ('/home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/python', '-c', 'import sys; print("%s%s" % sys.version_info[:2])') with kwargs {'shell': False}
2023-11-13 22:31:47,871 - mu.virtual_environment:475(run_subprocess) DEBUG: Process returned 0; output: 38
2023-11-13 22:31:47,871 - mu.virtual_environment:786(ensure_interpreter_version) INFO: Both interpreters at version 38
2023-11-13 22:31:47,871 - mu.virtual_environment:815(ensure_pip) INFO: Pip found at: /home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/pip
2023-11-13 22:31:47,871 - mu.virtual_environment:798(ensure_key_modules) DEBUG: Verifying import of: pgzero
2023-11-13 22:31:47,872 - mu.virtual_environment:463(run_subprocess) INFO: Running ('/home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/python', '-c', 'import pgzero') with kwargs {'shell': False}
2023-11-13 22:31:47,908 - mu.virtual_environment:475(run_subprocess) DEBUG: Process returned 0; output: No output received.
2023-11-13 22:31:47,909 - mu.virtual_environment:798(ensure_key_modules) DEBUG: Verifying import of: flask
2023-11-13 22:31:47,909 - mu.virtual_environment:463(run_subprocess) INFO: Running ('/home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/python', '-c', 'import flask') with kwargs {'shell': False}
2023-11-13 22:31:48,213 - mu.virtual_environment:475(run_subprocess) DEBUG: Process returned 0; output: No output received.
2023-11-13 22:31:48,213 - mu.virtual_environment:798(ensure_key_modules) DEBUG: Verifying import of: ipykernel
2023-11-13 22:31:48,213 - mu.virtual_environment:463(run_subprocess) INFO: Running ('/home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/python', '-c', 'import ipykernel') with kwargs {'shell': False}
2023-11-13 22:31:48,810 - mu.virtual_environment:475(run_subprocess) DEBUG: Process returned 0; output: No output received.
2023-11-13 22:31:48,810 - mu.virtual_environment:798(ensure_key_modules) DEBUG: Verifying import of: ipython_genutils
2023-11-13 22:31:48,810 - mu.virtual_environment:463(run_subprocess) INFO: Running ('/home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/python', '-c', 'import ipython_genutils') with kwargs {'shell': False}
2023-11-13 22:31:48,843 - mu.virtual_environment:475(run_subprocess) DEBUG: Process returned 0; output: No output received.
2023-11-13 22:31:48,843 - mu.virtual_environment:662(ensure_and_create) INFO: Valid virtual environment found at /home/brian/.local/share/mu/mu_venv-38-20231112-194901
2023-11-13 22:31:48,846 - mu.settings:169(save) DEBUG: Saving to /home/brian/.local/share/mu/venv.json
2023-11-13 22:31:48,866 - mu.logic:777(__init__) INFO: Setting up editor.
2023-11-13 22:31:48,870 - mu.logic:801(__init__) INFO: Log directory: /home/brian/.cache/mu/log
2023-11-13 22:31:48,870 - mu.logic:802(__init__) INFO: Data directory: /home/brian/.local/share/mu
2023-11-13 22:31:48,870 - mu.logic:816(setup) INFO: Available modes: python, snek, circuitpython, microbit, esp, web, pyboard, debugger, pygamezero, lego, pico
2023-11-13 22:31:48,870 - mu.modes.base:61(get_default_workspace) INFO: Using workspace /home/brian/mu_code from settings file
2023-11-13 22:31:48,935 - mu.modes.base:61(get_default_workspace) INFO: Using workspace /home/brian/mu_code from settings file
2023-11-13 22:31:48,935 - mu.logic:1583(change_mode) INFO: Workspace directory: /home/brian/mu_code
2023-11-13 22:31:48,935 - mu.logic:890(restore_session) DEBUG: <SessionSettings from /home/brian/.local/share/mu/session.json>
2023-11-13 22:31:48,942 - mu.logic:1015(_load) INFO: Loading script from: /home/brian/myApps/YTDLG3_1.py
2023-11-13 22:31:48,942 - mu.logic:332(read_and_decode) DEBUG: Trying to decode with utf-8
2023-11-13 22:31:48,942 - mu.logic:335(read_and_decode) INFO: Decoded with utf-8
2023-11-13 22:31:48,943 - mu.logic:348(read_and_decode) DEBUG: Detected newline '\n'
2023-11-13 22:31:48,943 - mu.logic:1114(_load) DEBUG: #!/usr/bin/python3
# -*- coding: utf-8 -*-
#############################################################################
from PyQt5.QtCore import (
    QFile,
    QPoint,
    QRect,
    QSize,
    QStandardPaths,
    Qt,
    QProcess,
    QSettings,
)
from PyQt5.QtGui import QIcon, QFont, QClipboard
from PyQt5.QtWidgets import (
    QAction,
    QApplication,
    QFileDialog,
    QMainWindow,
    QLineEdit,
    QProgressBar,
    QMessageBox,
    QHBoxLayout,
    QVBoxLayout,
    QWidget,
    QLabel,
    QMessageBox,
    QPushButton,
    QComboBox,
)

quote = str(chr(34))


class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        btnwidth = 150
        self.ytdlExec = ""
        self.ytUrl = ""
        self.OutFolder = "/tmp"
        self.settings = QSettings("YouTubeDL", "YTDL")
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.createStatusBar()
        pyfile = QStandardPaths.findExecutable("yt-dlp")
        if not pyfile == "":
            print("found " + pyfile)
            self.ytdlExec = pyfile
        else:
            self.msgbox("yt-dlp not found\nPlease install yt-dlp")

        self.cmd = ""
        self.process = QProcess(self)
        self.process.started.connect(lambda: self.showMessage("creating List"))
        self.process.finished.connect(
            lambda: self.showMessage("finished creating List")
        )
        self.process.finished.connect(self.processFinished)
        self.process.readyRead.connect(self.processOut)

        self.dlProcess = QProcess(self)
        self.dlProcess.setProcessChannelMode(QProcess.MergedChannels)
        self.dlProcess.started.connect(lambda: self.showMessage("download started"))
        self.dlProcess.finished.connect(lambda: self.showMessage("download finished"))
        self.dlProcess.finished.connect(
            lambda: self.setWindowTitle("YouTube Download GUI")
        )
        self.dlProcess.readyRead.connect(self.dlProcessOut)

        self.list = []

        self.setGeometry(0, 0, 600, 220)
        self.setFixedSize(600, 220)
        self.setStyleSheet(myStyleSheet(self))
        self.setWindowIcon(QIcon.fromTheme("youtube"))
        #### path
        lblUrl = QLabel()
        lblUrl.setText("insert URL:")
        lblUrl.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        lblUrl.setFixedWidth(btnwidth)
        lblUrl.setFont(QFont("Noto Sans", 9))
        self.lblURLpath = QLineEdit("")
        self.lblURLpath.setPlaceholderText(
            "insert URL and press ENTER to get list of available files"
        )
        self.lblURLpath.returnPressed.connect(self.fillCombo)

        hlayout = QHBoxLayout()
        hlayout.addWidget(lblUrl)
        hlayout.addWidget(self.lblURLpath)

        #### output path
        btnOutPath = QPushButton()
        btnOutPath.setFont(QFont("Noto Sans", 9))
        btnOutPath.setIcon(QIcon.fromTheme("gtk-open"))
        btnOutPath.setText("select Output Folder")
        btnOutPath.setFixedWidth(btnwidth)
        btnOutPath.clicked.connect(self.openOutFolder)
        self.lblOutPath = QLineEdit()
        self.lblOutPath.setPlaceholderText("insert output folder path")
        self.lblOutPath.textChanged.connect(self.updateOutputPath)

        hlayout2 = QHBoxLayout()
        hlayout2.addWidget(btnOutPath)
        hlayout2.addWidget(self.lblOutPath)

        #### ytdlExec path
        btnYTDLpath = QPushButton()
        btnYTDLpath.setFont(QFont("Noto Sans", 9))
        btnYTDLpath.setIcon(QIcon.fromTheme("document-open"))
        btnYTDLpath.setText("select youtube-dl")
        btnYTDLpath.setFixedWidth(btnwidth)
        btnYTDLpath.clicked.connect(self.selectYTDL)
        self.lblYTDLpath = QLineEdit(str(self.ytdlExec))
        self.lblYTDLpath.textChanged.connect(self.updatelblYTDLpath)
        self.lblYTDLpath.setPlaceholderText("insert path to youtube-dl")

        hlayout3 = QHBoxLayout()
        hlayout3.addWidget(btnYTDLpath)
        hlayout3.addWidget(self.lblYTDLpath)

        dlBtn = QPushButton()
        dlBtn.setIcon(QIcon.fromTheme("download"))
        dlBtn.setText("    Download")
        dlBtn.setFont(QFont("Noto Sans", 12))
        dlBtn.clicked.connect(self.downloadSelected)
        dlBtn.setFixedWidth(btnwidth)
        dlBtn.setFixedHeight(32)

        dlCancelBtn = QPushButton()
        dlCancelBtn.setIcon(QIcon.fromTheme("cancel"))
        dlCancelBtn.setText("      Cancel")
        dlCancelBtn.setFont(QFont("Noto Sans", 12))
        dlCancelBtn.clicked.connect(self.cancelDownload)
        dlCancelBtn.setFixedWidth(btnwidth)
        dlCancelBtn.setFixedHeight(32)

        self.dlCombo = QComboBox()
        self.dlCombo.setFixedHeight(26)

        self.pbar = QProgressBar()
        self.pbar.setFixedHeight(16)
        self.pbar.setFont(QFont("Helvetica", 7))
        self.pbar.setMaximum(100)
        self.pbar.setMinimum(0)
        self.pbar.setValue(0)

        btnLayout = QHBoxLayout()
        btnLayout.addWidget(dlBtn)
        btnLayout.addWidget(dlCancelBtn)

        vlayout = QVBoxLayout()
        vlayout.addLayout(hlayout)
        vlayout.addLayout(hlayout2)
        vlayout.addLayout(hlayout3)
        vlayout.addWidget(self.dlCombo)
        vlayout.addWidget(self.pbar)
        vlayout.addLayout(btnLayout)

        mywidget = QWidget()
        mywidget.setLayout(vlayout)

        self.setCentralWidget(mywidget)

        self.clip = QApplication.clipboard()
        if self.clip.text().startswith("http"):
            self.lblURLpath.setText(self.clip.text())
            self.fillCombo()
        # else:
        #    if len(self.clip.text()) < 12:
        #        self.lblURLpath.setText(self.clip.text())
        #        self.fillCombo()

        self.readSettings()
        self.setWindowTitle("YouTube Download GUI")

    def closeEvent(self, e):
        self.writeSettings()
        e.accept()

    def readSettings(self):
        print("reading settings")
        if self.settings.contains("geometry"):
            self.setGeometry(self.settings.value("geometry"))
        if self.settings.contains("outFolder"):
            self.lblOutPath.setText(self.settings.value("outFolder"))

    def writeSettings(self):
        print("writing settings")
        self.settings.setValue("outFolder", self.OutFolder)
        self.settings.setValue("geometry", self.geometry())

    def updateOutputPath(self):
        self.OutFolder = self.lblOutPath.text()
        self.showMessage("output path changed to: " + self.lblOutPath.text())

    def updatelblYTDLpath(self):
        self.ytdlExec = self.lblYTDLpath.text()
        self.showMessage("youtube-dl path changed to: " + self.lblYTDLpath.text())

    def showMessage(self, message):
        self.statusBar().showMessage(message, 0)

    def selectYTDL(self):
        fileName, _ = QFileDialog.getOpenFileName(
            self, "locate ytdlExec", "/usr/local/bin/ytdlExec", "exec Files (*)"
        )
        if fileName:
            self.lblYTDLpath.setText(fileName)
            self.ytdlExec = fileName

    def openOutFolder(self):
        dlg = QFileDialog()
        dlg.setFileMode(QFileDialog.Directory)
        fileName = dlg.getExistingDirectory()
        if fileName:
            self.lblOutPath.setText(fileName)

    def fillCombo(self):
        self.dlCombo.clear()
        if QFile.exists(self.ytdlExec):
            self.list = []
            self.ytUrl = self.lblURLpath.text()
            if not self.lblURLpath.text() == "":
                print("fill Combo")
                self.process.start(self.ytdlExec, ["-F", self.ytUrl])
        else:
            self.showMessage("youtube-dl missing")

    def processOut(self):
        try:
            output = str(self.process.readAll(), encoding="utf8").rstrip()
        except Error:
            output = str(self.process.readAll()).rstrip()
        self.list.append(output)

    def processFinished(self):
        out = ",".join(self.list)
        mylist = out.rsplit("\n")[2:]
        self.dlCombo.addItems(mylist)
        count = self.dlCombo.count()
        self.dlCombo.setCurrentIndex(count - 1)

    def downloadSelected(self):
        if QFile.exists(self.ytdlExec):
            self.pbar.setValue(0)
            quality = self.dlCombo.currentText().partition(" ")[0]
            options = []
            options.append("-f")
            options.append(quality)
            options.append("--add-metadata")
            options.append("-o")
            options.append("%(title)s.%(ext)s")
            options.append(self.ytUrl)
            if not quality == "":
                self.showMessage("download started")
                print("download selected quality:", quality)
                self.dlProcess.setWorkingDirectory(self.OutFolder)
                self.dlProcess.start(self.ytdlExec, options)
            else:
                self.showMessage("list of available files is empty")
        else:
            self.showMessage("youtube-dl missing")

    def dlProcessOut(self):
        try:
            out = str(self.dlProcess.readAll(), encoding="utf8").rstrip()
        except Error:
            out = str(self.dlProcess.readAll()).rstrip()
        out = out.rpartition("[download] ")[2]
        self.showMessage("Progress: " + out)
        self.setWindowTitle(out)
        out = out.rpartition("%")[0].rpartition(".")[0]
        if not out == "":
            try:
                pout = int(out)
                self.pbar.setValue(pout)
            except ValueError:
                pass

    def cancelDownload(self):
        if self.dlProcess.state() == QProcess.Running:
            print("process is running, will be cancelled")
            self.dlProcess.close()
            self.showMessage("Download cancelled")
            self.pbar.setValue(0)
        else:
            self.showMessage("process is not running")

    def createStatusBar(self):
        self.statusBar().showMessage("Ready")

    def msgbox(self, message):
        QMessageBox.warning(self, "Message", message)


def myStyleSheet(self):
    return """

QStatusBar
{
font-family: Helvetica;
font-size: 8pt;
color: #666666;
}
QProgressBar:horizontal {
border: 1px solid gray;
border-radius: 2px;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #d3d3d3, stop:1 #e9e9e9);
padding: 1px;
text-align: right;
margin-right: 4ex;
}
QProgressBar::chunk:horizontal
{
background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 blue, stop: 1 white);
margin-right: 2px;
width: 8px;
}
QMenuBar
{
background: transparent;
border: 0px;
}
QToolBar
{
background: transparent;
border: 0px;
}
QMainWindow
{
     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                 stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
                                 stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
}
QLineEdit
{
     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                 stop: 0 #E1E1E1, stop: 0.4 #e5e5e5,
                                 stop: 0.5 #e9e9e9, stop: 1.0 #d2d2d2);
}
QPushButton
{
background: #D8D8D8;
}
QPushButton::hover
{
background: #729fcf;
}
QComboBox
{
background: #D8D8D8;
}
    """


if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    mainWin = MainWindow()
    mainWin.show()
    sys.exit(app.exec_())

2023-11-13 22:31:49,069 - mu.logic:1015(_load) INFO: Loading script from: /Daten_HD/shared_python_files/gtk4/gtk4_player_axel.py
2023-11-13 22:31:49,069 - mu.logic:332(read_and_decode) DEBUG: Trying to decode with utf-8
2023-11-13 22:31:49,069 - mu.logic:335(read_and_decode) INFO: Decoded with utf-8
2023-11-13 22:31:49,069 - mu.logic:348(read_and_decode) DEBUG: Detected newline '\n'
2023-11-13 22:31:49,069 - mu.logic:1114(_load) DEBUG: #!/usr/bin/env python3

import sys
import gi

gi.require_version("WebKit", "6.0")
gi.require_version("Gtk", "4.0")
gi.require_version("Gdk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk, Gdk, Adw, Gio, GLib, WebKit

CSS = """
#myheaderbar, #myappwindow {
    background: black;
    color: lightgray;
}
#myplayer {
    margin-bottom: 5px;
}
"""


class MainWindow(Gtk.ApplicationWindow):
    def __init__(self, *args, **kwargs):
        super().__init__(title="Video Player", *args, **kwargs)

        self.set_name("myappwindow")
        self.current_folder = Gio.File.new_for_path(
            GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_VIDEOS)
        )

        action = Gio.SimpleAction.new("Open", None)
        action.connect("activate", self.open_file)
        self.add_action(action)

        css_provider = Gtk.CssProvider()
        css_provider.load_from_data(bytes(CSS.encode()))
        Gtk.StyleContext.add_provider_for_display(
            Gdk.Display.get_default(),
            css_provider,
            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
        )

        self.header_bar = Gtk.HeaderBar.new()
        self.header_bar.set_name("myheaderbar")
        self.set_titlebar(titlebar=self.header_bar)

        btn_open = Gtk.Button.new_from_icon_name("document-open")
        btn_open.set_tooltip_text("Open File")
        btn_open.connect("clicked", self.open_file)
        self.header_bar.pack_start(btn_open)

        btn_url = Gtk.Button.new_from_icon_name("edit-paste")
        btn_url.set_tooltip_text("Open URL from clipboard")
        btn_url.connect("clicked", self.open_url)
        self.header_bar.pack_start(btn_url)

        self.view = WebKit.WebView()

        self.video_file = ""
        self.player = Gtk.Video.new()
        self.player.set_name("myplayer")
        self.player.set_autoplay(True)

        if len(sys.argv) > 1:
            self.video_file = sys.argv[1]
            self.player.set_file(Gio.File.new_for_path(self.video_file))
            print("Video:", self.player.props.file.get_parse_name())
            self.set_child(self.player)
        self.set_size_request(320, 230)
        self.set_default_size(640, 406)

        self.clipboard = Gdk.Display.get_default().get_clipboard()

        self.file_filter_videos = Gtk.FileFilter()
        self.file_filter_videos.set_name("Video Files")
        # pattern = ["*.mp4", "*.mov", "*.vob", "*.ts", "*.mpg", "*.3gp", "*.m4v*", "*.mpeg"]
        # for p in pattern:
        #    self.file_filter_videos.add_pattern(p)
        mime_types = [
            "video/mp4",
            "video/quicktime",
            "video/webm",
            "video/mpeg",
            "video/x-msvideo",
            "video/3gpp",
        ]
        for vid in mime_types:
            self.file_filter_videos.add_mime_type(vid)

    def open_file(self, *args):
        print("open file")
        self.show_open_dialog()

    def open_url(self, *args):
        self.clipboard.read_text_async(None, self.on_paste_text)

    def on_paste_text(self, clipboard, result, *args):
        url = self.clipboard.read_text_finish(result)
        if url is not None:
            self.view.load_uri(url)
            self.set_child(self.view)

    def show_open_dialog(self):
        dialog = Gtk.FileChooserDialog(
            title="Open", action=Gtk.FileChooserAction.OPEN, modal=True
        )
        dialog.set_current_folder(self.current_folder)
        dialog.add_buttons(
            "_Cancel", Gtk.ResponseType.CANCEL, "_Open", Gtk.ResponseType.ACCEPT
        )
        dialog.add_filter(self.file_filter_videos)
        dialog.set_transient_for(self)
        open_button = dialog.get_widget_for_response(Gtk.ResponseType.ACCEPT)
        open_button.add_css_class("suggested-action")
        cancel_button = dialog.get_widget_for_response(Gtk.ResponseType.CANCEL)
        cancel_button.add_css_class("destructive-action")
        dialog.connect("response", self.on_open_dialog_response)
        dialog.show()

    def on_open_dialog_response(self, dialog, response_id):
        if response_id == Gtk.ResponseType.ACCEPT:
            self.set_child(self.player)
            filename = str(dialog.get_file().get_path())
            print(f"loading {filename}")
            self.video_file = filename
            self.player.set_file(Gio.File.new_for_path(self.video_file))
            name = filename.split("/")[-1].split(".")[-2]
            self.set_title(name)

        dialog.destroy()


class MyApp(Adw.Application):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.connect("activate", self.on_activate)
        self.connect("open", self.on_activate)
        self.set_flags(Gio.ApplicationFlags.HANDLES_OPEN)
        self.win = None

    def lol(self, keyval, keycode, state, user_data, win):
        if keycode == ord("q"):
            win.close()
        if keycode == ord("f"):
            if win.is_fullscreen():
                win.unfullscreen()
            else:
                win.fullscreen()

    def on_activate(self, app, *args, **kwargs):
        self.win = MainWindow(application=app)
        self.win.present()
        keycont = Gtk.EventControllerKey()
        keycont.connect("key-pressed", self.lol, self.win)
        self.win.add_controller(keycont)


app = MyApp()
app.run(sys.argv)

2023-11-13 22:31:49,096 - mu.logic:912(restore_session) INFO: Loaded files.
2023-11-13 22:31:49,096 - mu.logic:918(restore_session) INFO: User defined environment variables: {}
2023-11-13 22:31:49,097 - mu.logic:923(restore_session) INFO: Minify scripts on micro:bit? False
2023-11-13 22:31:49,131 - mu.modes.base:61(get_default_workspace) INFO: Using workspace /home/brian/mu_code from settings file
2023-11-13 22:31:49,131 - mu.logic:1583(change_mode) INFO: Workspace directory: /home/brian/mu_code
2023-11-13 22:31:52,033 - mu.logic:1439(show_admin) INFO: Showing admin with logs from /home/brian/.cache/mu/log/mu.log
2023-11-13 22:31:52,033 - mu.virtual_environment:984(installed_packages) INFO: Discovering installed third party modules in venv.
2023-11-13 22:31:52,033 - mu.virtual_environment:139(run_blocking) INFO: About to run blocking /home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/pip with args ['list', '--disable-pip-version-check'] and envvars {}
2023-11-13 22:31:52,665 - mu.virtual_environment:189(wait) DEBUG: Finished: True; exitStatus 0; exitCode 0
2023-11-13 22:31:52,665 - mu.virtual_environment:274(run) DEBUG: Process output: Package           Version
----------------- -------
asttokens         2.1.0
backcall          0.2.0
click             8.1.3
decorator         5.1.1
entrypoints       0.4
executing         1.2.0
Flask             2.0.3
ipykernel         5.5.6
ipython           8.6.0
ipython-genutils  0.2.0
itsdangerous      2.1.2
jedi              0.18.1
Jinja2            3.1.2
jupyter_client    7.4.6
jupyter_core      5.0.0
MarkupSafe        2.1.1
matplotlib-inline 0.1.6
nest-asyncio      1.5.6
numpy             1.23.4
parso             0.8.3
pexpect           4.8.0
pgzero            1.2.1
pickleshare       0.7.5
pip               23.3.1
platformdirs      2.5.4
prompt-toolkit    3.0.32
ptyprocess        0.7.0
pure-eval         0.2.2
pygame            2.1.2
Pygments          2.13.0
PyQt5             5.15.10
PyQt5-Qt5         5.15.2
PyQt5-sip         12.13.0
PyQtWebEngine     5.15.6
PyQtWebEngine-Qt5 5.15.2
python-dateutil   2.8.2
pyzmq             24.0.1
setuptools        65.6.3
six               1.16.0
stack-data        0.6.1
tornado           6.2
traitlets         5.5.0
wcwidth           0.2.5
Werkzeug          2.2.2
wheel             0.38.4
2023-11-13 22:31:52,665 - mu.virtual_environment:993(installed_packages) INFO: ['PyQt5', 'PyQt5-Qt5', 'PyQt5-sip', 'PyQtWebEngine', 'PyQtWebEngine-Qt5']
2023-11-13 22:31:58,495 - mu.logic:1513(sync_package_state) INFO: Synchronize package states...
2023-11-13 22:31:58,495 - mu.logic:1514(sync_package_state) INFO: Old: {'pyqtwebengine-qt5', 'pyqt5', 'pyqt5-qt5', 'pyqtwebengine', 'pyqt5-sip'}
2023-11-13 22:31:58,495 - mu.logic:1515(sync_package_state) INFO: New: {'pyqtwebengine-qt5', 'pyqt5', 'pygobject', 'pyqt5-qt5', 'pyqtwebengine', 'pyqt5-sip'}
2023-11-13 22:31:58,495 - mu.logic:1519(sync_package_state) INFO: To add: {'pygobject'}
2023-11-13 22:31:58,495 - mu.logic:1520(sync_package_state) INFO: To remove: set()
2023-11-13 22:31:58,495 - mu.logic:1521(sync_package_state) INFO: Virtualenv: /home/brian/.local/share/mu/mu_venv
2023-11-13 22:31:58,499 - mu.virtual_environment:967(install_user_packages) INFO: Installing user packages: pygobject
2023-11-13 22:31:58,500 - mu.virtual_environment:152(run) INFO: About to run /home/brian/.local/share/mu/mu_venv-38-20231112-194901/bin/pip with args ['install', '--disable-pip-version-check', '--upgrade', 'pygobject'] and envvars {}
2023-11-13 22:32:14,168 - mu.settings:169(save) DEBUG: Saving to /home/brian/.local/share/mu/session.json
2023-11-13 22:32:14,169 - mu.logic:1430(quit) INFO: Quitting.


2023-11-13 22:32:14,169 - mu.settings:169(save) DEBUG: Saving to /home/brian/.local/share/mu/session.json
2023-11-13 22:32:14,170 - mu.settings:169(save) DEBUG: Saving to /home/brian/.local/share/mu/venv.json
@carlosperate
Copy link
Member

Hi @Axel-Erfurt

Looks like PyGObject is only distributed as a source package, which means it needs to be built every time it is pip installed.

Do you have the build tools installed and available in the PATH? If you run pip install PyGObject in a virtual environment outside of Mu, does it build and install correctly?

@Axel-Erfurt
Copy link
Author

If you run pip install PyGObject in a virtual environment outside of Mu, does it build and install correctly?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants