小编Jos*_*eph的帖子

从按键事件设置小部件

当我按空格键时,我正在尝试设置一个小部件。我有一个包含 QLabel 的 QGridLayout。我想从 QGridLayout 中的坐标设置特定 Qlabel 的文本,但是当我从按键函数访问 QGridLayout 时,该变量为空。

import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize    

class Position:
   def __init__(self, x, y):
      self.x = x
      self.y = y

class HelloWindow(QMainWindow):
    global gridLayout
    def __init__(self):
        QMainWindow.__init__(self)

        self.setMinimumSize(QSize(640, 640))    
        self.setWindowTitle("Hello world") 

        centralWidget = QWidget(self)          
        self.setCentralWidget(centralWidget)   

        gridLayout = QGridLayout(self)
        gridLayout.setSpacing(0)  
        centralWidget.setLayout(gridLayout)  

        file_text = open("logic/file.txt", "r")
        file = file_text.read()
        file = file.replace("[(","")
        file = file.replace(")]","")
        file = file.replace("),(",";")
        positions = file.split(';')
        lista …
Run Code Online (Sandbox Code Playgroud)

python pyqt python-3.x pyqt5

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

从标题的右键导航 - React Native

我正在尝试从标题按钮导航,但我不能,因为找不到导航变量。

这是我的代码

export const createRootNavigator = (signedIn = false) => {

return StackNavigator(
  {
    SignedIn: {
      screen: SignedIn,
      navigationOptions: {
        gesturesEnabled: false,
        headerStyle,
        headerTintColor: "white",
        headerTitleStyle,
        headerLeft: null,
        headerRight: <TouchableOpacity style={ [{paddingHorizontal:15}] }
                        onPress={() => navigation.navigate({ routeName: 'Notification'})}>
                        <Icon
                          name="md-notifications-outline"
                          size={26}
                          style={{ color: "white" }}/>
                      </TouchableOpacity>,


      }
    },
    SignedOut: {
      screen: SignedOut,
      navigationOptions: {
        gesturesEnabled: false
      }
    },
    Notification: {
      screen: Notification,
      navigationOptions: {
        gesturesEnabled: false
      }
    }
  },
  {
    mode: "modal",
    initialRouteName: signedIn ? "SignedIn" : "SignedOut"
  }
); …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-navigation stack-navigator

0
推荐指数
1
解决办法
2922
查看次数