小编Ach*_*yan的帖子

分段故障捕获

我有一个 python 脚本,它会遍历一堆 Maya 文件并做一些事情。但有一段时间玛雅会出现段错误,我的脚本会停在那里。我尝试了信号和多进程。但都失败了

import os, optparse, glob, json, signal
import maya.standalone
import maya.cmds as cmds
from multiprocessing import Process, Queue

def loadMayaBd():
    maya.standalone.initialize(name='python')

def sig_handler(signum, frame):
    print "segfault"

def doSome(args, options):
    signal.signal(signal.SIGSEGV, sig_handler)
    loadMayaBd()
    #from here its just a example
    fileNameList = args[0]
    for eachFile in fileNameList:
        #this is throwing the seg fault
        #I want continue my for llop even if there is any segfault
        #I don't want to exit python coz of that segfault
        cmds.file(eachFile, force = …
Run Code Online (Sandbox Code Playgroud)

python signals multiprocessing maya segmentation-fault

9
推荐指数
1
解决办法
1万
查看次数

如何使用QPainterPath创建文本以及曲线

我正在尝试用一些文本构建一个弧.我能够创建弧,我可以将文本与曲线一起放置.但到目前为止,我找不到一种垂直于曲线旋转文本的方法.

这是我正在尝试的代码

from __future__ import division
import os
import sys
from PyQt4 import QtGui,QtCore
import math

class PathPaintTest(QtGui.QFrame):


    def __init__(self, *args):
        super (PathPaintTest, self).__init__(*args)
        self.setMaximumSize(250, 110)
        self.setMinimumSize(250, 110)
        self.setFrameShape(QtGui.QFrame.WinPanel)
        self.setFrameShadow(QtGui.QFrame.Sunken)

    def paintEvent(self, event):
        hw = QtCore.QString("Hello World")
        drawWidth = self.width() / 100
        painter = QtGui.QPainter(self)
        pen = painter.pen()
        pen.setWidth(drawWidth)
        pen.setColor(QtGui.QColor(QtCore.Qt.red))
        painter.setPen(pen)
        painter.translate(5,0)
        cc1 = QtCore.QPointF(5, -15)
        cc2 = QtCore.QPointF(220, -15)
        path1 = QtGui.QPainterPath(QtCore.QPointF(5, 140))
        path1.cubicTo(cc1, cc2, QtCore.QPointF(240, 140))
        painter.drawPath(path1)

        pen.setColor(QtGui.QColor(QtCore.Qt.yellow))
        painter.setPen(pen)
        font = painter.font()
        font.setPixelSize(drawWidth * 5)
        painter.setFont(font)
        percentIncrease = …
Run Code Online (Sandbox Code Playgroud)

python pyqt qpainter

5
推荐指数
1
解决办法
1846
查看次数

在sublime 3 api中将文本插入视图

我现在在我的崇高中有 4 个视图。我想在一个视图中插入一些文本。我正在尝试这样。但没有运气。

getAllViews = self.window.views()
jobView = getAllViews[1]
jobEdit = jobView.begin_edit()
jobView.insert(jobEdit, 0, 'Hello')
jobView.end_edit(jobEdit)
Run Code Online (Sandbox Code Playgroud)

有没有更好的想法来做到这一点?

更新我的问题

我正在将当前视图布局编辑为 4 窗格布局,并且我想将一些差异数据添加到我新创建的布局中。我现在有这个代码。

import sublime
import sublime_plugin
import os, subprocess

class SpliterCommand(sublime_plugin.TextCommand):
    def on_done(self, Regex):
        self.window.set_layout({
            "cols": [0, 0.5, 1],
            "rows": [0.0, 0.33, 0.66, 1.0],
            "cells": [ [0, 0, 1, 3], [1, 0, 2, 1], [1, 1, 2, 2], [1, 2, 2, 3]]
                })

    def run(self, edit):
        self.editview = edit
                self.window = sublime.active_window()
        self.window.show_input_panel('User Input', "Hello",self.on_done,None,None)
        getAllViews = self.window.layouts()
Run Code Online (Sandbox Code Playgroud)

这会将 ui 拆分为 …

python sublimetext3 sublime-text-plugin

5
推荐指数
1
解决办法
1163
查看次数

什么是从pyqt中的布局中删除项目的最佳方法

我在pyqt中遇到布局问题.如果layout.count()返回旧项目计数,则仍然关闭布局中的项目.所以我认为.close()并没有真正从布局中删除项目.这是一个完整的工作示例.

import sys
from PyQt4 import QtGui,QtCore
class LayoutTest(QtGui.QWidget):
    def __init__(self):
        super(LayoutTest, self).__init__()
        self.vvbox = QtGui.QVBoxLayout()
        self.dvbox = QtGui.QVBoxLayout()
        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(self.vvbox)
        vbox.addLayout(self.dvbox)
        self.setLayout(vbox)

        self.add_button = QtGui.QPushButton("Add Items")
        self.edit_button = QtGui.QPushButton("Remove Items")
        self.chk_button = QtGui.QPushButton("Check Items")

        self.vvbox.addWidget(self.add_button)
        self.vvbox.addWidget(self.edit_button)
        self.vvbox.addWidget(self.chk_button)

        self.connect(self.add_button, QtCore.SIGNAL("clicked()"), self.addButtons)
        self.connect(self.edit_button, QtCore.SIGNAL("clicked()"), self.removeButtons)
        self.connect(self.chk_button, QtCore.SIGNAL("clicked()"), self.checkItems)

        self.setGeometry(300, 200, 400, 300)

    def keyPressEvent(self, event):
        if event.key() == QtCore.Qt.Key_Escape:
            self.close()

    def addButtons(self):
        for i in range(0, 5):
            self.r_button = QtGui.QPushButton("Button %s " % i)
            self.dvbox.addWidget(self.r_button)

    def removeButtons(self):
        for cnt …
Run Code Online (Sandbox Code Playgroud)

python layout pyqt qwidget

3
推荐指数
1
解决办法
7549
查看次数

振动不适用于通知

我试图设置振动和声音通知.由于某种原因它不适合我:(这是我正在尝试的代码

NotificationManager notificationManager = getNotificationManager();
        NotificationCompat.Builder builder = new NotificationCompat.Builder(
                context);
        builder.setSound(alarmSound);
        builder.setVibrate(new long[] { 1000, 1000, 1000 });
        Notification notification = builder.setContentIntent(contentIntent)
                .setSmallIcon(icon).setTicker(title).setWhen(0)
                .setAutoCancel(true).setContentTitle(title).setPriority(Notification.PRIORITY_HIGH)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(msgToDisply))
                .setContentText(msgToDisply).build();
        notificationManager.notify(NOTIFICATION, notification);
        stopSelf();
Run Code Online (Sandbox Code Playgroud)

public NotificationManager getNotificationManager() {
        return (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    }
Run Code Online (Sandbox Code Playgroud)

我的证词中有我的许可

<uses-permission android:name="android.permission.VIBRATE" />
Run Code Online (Sandbox Code Playgroud)

有什么想法发生了什么?

android android-notifications android-vibration

2
推荐指数
2
解决办法
5231
查看次数